Selenium + Mink + Chrome:“无法打开连接”错误

时间:2018-01-30 15:26:14

标签: selenium selenium-chromedriver mink

我不是设置Selenium和Mink的新手,但它似乎总是很麻烦。这次我试图在ubuntu docker容器中设置它并且我遇到了以下错误

  Could not open connection: Unable to create new service: ChromeDriverService
  Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
  System info: host: 'a75b4026b8e5', ip: '172.20.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.60-linuxkit-aufs', java.version: '1.8.0_161'
  Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)

我可以说Mink正在某种程度上击中Selenium,因为Selenium服务器在Behat报告上述错误之前立即输出以下内容:

2018-01-30 16:13:49.870:INFO:osjshC.ROOT:qtp1156060786-12: org.openqa.selenium.remote.server.WebDriverServlet-10bbd20a: Initialising WebDriverServlet
16:13:49.988 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@4b4945b7
16:13:50.006 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.168 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.171 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:13:50.302 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@5a608e4b
16:13:50.303 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.306 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.307 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

知道我错了什么设置吗?

以下是我的设置:

我安装的chromedriver版本:

https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip

我通过apt-get install google-chrome-stable命令安装的Chrome版本:

Google Chrome 64.0.3282.119

已安装的Java版本:

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

我是如何开始使用硒的:

xvfb-run --server-args="-screen 0, 1366x768x24" java -Dwebdriver.chrome.driver="usr/bin/chromedriver" -jar selenium-server-standalone-3.8.1.jar &

composer.json:

    ...
    "require-dev": {
        "behat/behat": "^3.1",
        "behat/mink": "^1.7",
        "behat/mink-extension": "^2.2",
        "behat/mink-goutte-driver": "^1.2",
        "behat/mink-selenium2-driver": "^1.3",
       ...
    }, 

behat.yml:

extensions:
    Behat\MinkExtension:
      goutte: ~
      base_url: http://localhost/myapp/
      browser_name: chrome
      javascript_session: selenium2
      default_session: goutte
      selenium2:
        wd_host: "http://127.0.0.1:4444/wd/hub"
        capabilities:
          marionette: true
          browser: chrome
          version: 2.9

0 个答案:

没有答案