Facebook / php-webdriver与Selenium / Firefox / Gecko:WebDriverCurlException / EOF阅读木偶消息

时间:2017-05-02 18:28:40

标签: firefox selenium

我想在Firefox中使用facebook/php-webdriver。 我有Selenium 3.4 jar,Firefox 52.1和Geckodriver 16.1(使其可执行并将文件夹添加到PATH)。

我安装了Firefox和Xvfb,因为我已经阅读了这些命令所需的内容:

sudo yum install firefox Xvfb libXfont Xorg
Xvfb :99 -ac -screen 0 1280x1024x24 &
export DISPLAY=:99

我使用提供的Geckodriver运行Selenium,并使用以下命令:

java -Dwebdriver.gecko.driver="/opt/bin/geckodriver" -jar  selenium-server-standalone-3.4.0.jar

这是我的php文件中的代码:

namespace Facebook\WebDriver;

include("vendor/autoload.php");

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

$host = "http://localhost:4444/wd/hub";
$profile = new Firefox\FirefoxProfile();
$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability(Firefox\FirefoxDriver::PROFILE, $profile);
$capabilities->setCapability('marionette', true);
$driver = RemoteWebDriver::create($host, $capabilities);

$driver->get("http://www.google.nl");
$driver->manage()->timeouts()->implicitlyWait = 10;

Selenium会运行,但我在终端connection refusedAssertion failure .. Should successfully create image decoding中看到了这些错误。

在浏览器中,我看到以下错误消息:

Uncaught exception 'Facebook\WebDriver\Exception\WebDriverCurlException' with message 'Curl error thrown for http POST to /session

如果我尝试其他网址,我会收到EOF reading marionette message

如何使Selenium正常工作?

1 个答案:

答案 0 :(得分:0)

我也不能使用firefox和seleium。我的错误信息不同。但也许问题是一样的。

安装java后,它会自动打开页面:
https://java.com/zh_TW/download/installed8.jsp

Firefix表示,自2017年3月发布的firefox 52版以来,它们对插件有限制。 Chrome表示它不支持NPAPI,因此它不会执行所有java。

也许这是导致问题的原因?

Firefox错误

Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\UnknownServerException' with message 'The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases' in D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:114 Stack trace: #0 D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(13, 'The path to the...', Array) #1 D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php(126): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #2 D:\wwwroot\example\httpdocs\test.php(19): Facebook\WebDriver\Remote\RemoteWebDriver::create('http://local in D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Exception\WebDriverException.php on line 114

Chrome错误

Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\UnknownServerException' with message 'The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases' in D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:114 Stack trace: #0 D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php(320): Facebook\WebDriver\Exception\WebDriverException::throwException(13, 'The path to the...', Array) #1 D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php(126): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand)) #2 D:\wwwroot\example\httpdocs\test.php(19): Facebook\WebDriver\Remote\RemoteWebDriver::create('http://local in D:\wwwroot\example\httpdocs\vendor\facebook\webdriver\lib\Exception\WebDriverException.php on line 114