让WebDriver使用Firefox

Har*_*osh 5 selenium webdriver codeception

使用Laravel 5+和Vagrant.

我用selenium运行:

java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox"
Run Code Online (Sandbox Code Playgroud)

使用无头显示器:

sudo Xvfb :10 -ac
Run Code Online (Sandbox Code Playgroud)

但是,当我运行代码时:

 ./vendor/bin/codecept run selenium --steps
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

[Facebook\WebDriver\Exception\UnknownServerException] 45000 ms后无法在端口7055上连接到主机127.0.0.1.Firefox控制台输出:错误:GDK_BACKEND与可用显示不匹配

我对我应该使用的服务器和端口感到困惑.目前我访问的网站通过http://localhost:8000 外面的流浪汉.

$url = 'http://localhost:4444/wd/hub'在里面观察api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php

由于错误输出:

127.0.0.1在端口7055上.

Har*_*osh 3

切换到 Chrome Web 驱动程序,更简单,更兼容,并且对我来说工作得很好。

  1. 下载 chrome webdriver 或composer require
  2. 设置环境

    nohup sudo Xvfb :10 -ac &

    导出显示=:10

    java -jar供应商/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin /chromedriver”

  • 为什么这是被接受的答案?“使用 chrome”绝对不是“让 WebDriver 与 Firefox 一起工作”的有效答案 (6认同)