Firefox与selenium-server-standalone-2.45.0

时间:2015-04-02 16:46:29

标签: php google-chrome firefox selenium mink

我已按照教程: 的github [点] com / aik099 / EN-貂[点]贝哈特[点]组织/斑点/主/指数[点] RST

在php脚本上运行Mink/selenium

我正在使用Firefox 28运行selenium-server-standalone-2.45.0(从版本37开始),但继续收到错误:

Fatal error: Uncaught exception 'WebDriver\Exception\UnknownError' with message 'Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: no display specified Error: no display specified  in...

在线搜索错误时,我发现我应该将Firefox降级到35以下以获取当前的硒版本。那我还在做什么呢?

然后我去安装谷歌浏览器,出现以下错误:

Fatal error: Uncaught exception 'WebDriver\Exception\UnknownError' with message 'The path to the driver executable must be set by the webdriver.opera.driver system property;

有关更多信息,请参阅github [dot] com / operasoftware / operachromiumdriver。最新版本可以从github [dot] com / operasoftware / operachromiumdriver / releases'下载。在...

额外信息: 在安装了centos 6的VPS上运行此脚本。

代码的PHP脚本:

    <?php
require_once 'vendor/autoload.php';

$driver = new \Behat\Mink\Driver\Selenium2Driver(
    'firefox', 'thewebsitebase'
);
//have replace firefox with google-chrome

// init session:
$session = new \Behat\Mink\Session($driver);

// start session:
$session->start();

// open some page in browser:
$session->visit('thewebsite');

// get the current page URL:
echo $session->getCurrentUrl();

// get the response status code:
echo $session->getStatusCode();

// get page content:
echo $session->getPage()->getContent();

// evaluate JS expression:
echo $session->evaluateScript(
    "return 'something from browser';"
);

?>

0 个答案:

没有答案