首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >链接webdriver方法

链接webdriver方法
EN

Stack Overflow用户
提问于 2019-03-15 06:51:49
回答 1查看 42关注 0票数 0

我想实现一个类来执行一些常见的out驱动程序功能,但我总是得到:驱动程序服务器已死。

如下所示:

代码语言:javascript
复制
class mywebdriver {

    function __construct( $args ){

        //options
        $options = new ChromeOptions();
        $options->addArguments($args);

        //capabilities
        $caps = DesiredCapabilities::chrome();
        $caps->setCapability(ChromeOptions::CAPABILITY, $options);
        $driver = ChromeDriver::start($caps);
        $driver->manage()->timeouts()->implicitlyWait = 20;

        $this->driver = $driver;    
    }

    function login(){       
        //all things related to logging into a site using $this->driver
        $this->driver->get( "www.url.com" );
    }

    function logout(){      
        //all things related to logging into a site using $this->driver
        $this->driver->quit();
    }

    function search( $value ){      
        //enter a value in the search field and print results
    }

    ... other methods
}

然后,链接这些方法,例如:

代码语言:javascript
复制
$drive = new mywebdriver();
try {
    $drive->login()
        ->search( "toyota" )
        ->search( "ford" )
        ->logout();
} catch (Exception $e) {
    echo "Caught Exception". $e->getMessage();
}

这是典型的,也是可能的吗?我尝试了一些方法,但是驱动服务器一直给我一个“已死”的异常。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55173176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档