Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Issue with chromedriver when running Behat tests 1404 box version 1.1.7 #1152

Closed
devert opened this issue Feb 2, 2017 · 64 comments
Closed

Comments

@devert
Copy link

devert commented Feb 2, 2017

Synopsis / Proposed Solutions

  • It looks like sometime in the Chrome 56 release cycle, the version that's installed on Ubuntu 14.04 has broken the ability to use Selenium + chromedriver for Behat tests.
  • One fix is to switch to the ubuntu1604 or centos7 (or any other newer OS version base box).
  • Another fix is to switch to PhantomJS instead of chromedriver (see here if you're using Acquia BLT)
  • Another fix is to switch to Firefox + geckodriver + xvfb
  • Another fix is to use a Docker container (e.g. https://github.com/SeleniumHQ/docker-selenium) to run Selenium tests (instead of setting them to run inside the VM using the selenium installed_extra).

Basically, the bug seems to be upstream in either Google Chrome for Ubuntu 14.04, or in Chromedriver, as we've collectively spent a few dozen hours debugging everything (even trying Selenium 3.x and other exotic things), and nobody has figured out why the exact same configuration randomly stopped working in Ubuntu 14.04 sometime around the beginning of February.

Original Issue Description

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 1.8.7
VirtualBox 5.1.8r111374
ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides

Your OS

  • macOS (10.10.5)

Full console output

https://gist.github.com/devert/e1f393ebb143fb8f5a6327fb2d267c42

Summary

After updating from 1.1.6 to the latest box geerlingguy/ubuntu1404 (virtualbox, 1.1.7) and reprovisioning the machine, I am now receiving an error when trying to run Behat tests. I wasn't recieving errors with chromedriver before.

@geerlingguy
Copy link
Owner

Just for quicker reference:

  @javascript
  Scenario: Load a page with Javascript # features/Examples.feature:9
    Given I am on "/"                   # Drupal\DrupalExtension\Context\MinkContext::visit()
      Could not open connection: chrome not reachable
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.13.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace in

formation)
      Command duration or timeout: 114.38 seconds
      Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
      System info: host: 'local', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.7.0_121'
      Driver info: org.openqa.selenium.chrome.ChromeDriver (Behat\Mink\Exception\DriverException)
    Then I should see the text "Log in" # Drupal\DrupalExtension\Context\MinkContext::assertTextVisible()

--- Failed scenarios:

    features/Examples.feature:9

1 scenario (1 failed)

2 steps (1 failed, 1 skipped)
1m57.65s (31.22Mb)
  [foreach] /var/www/opa/vendor/acquia/blt/phing/tasks/tests.xml:89:8: /var/www/opa/vendor/acquia/blt/phing/tasks/tests.xml:104:1: Behat exited with code 1

BUILD FAILED/var/www/opa/vendor/acquia/blt/phing/tasks/tests.xml:30:31: Execution of the target buildfile failed. Aborting.
; 2 minutes  6.89 seconds

Specifically:

Could not open connection: chrome not reachable

Can you restart your VM (vagrant reload) and try again? Sometimes chromedriver just seems to lock up, go away, or go into ghost mode...

@devert
Copy link
Author

devert commented Feb 3, 2017

@geerlingguy Tried to do a vagrant reload. Slightly different error output this time, but ultimately still due to being unable to establish a connection to Chrome.

blt > tests:selenium:kill:
     [echo] Killing any selenium processes that are already running.
     [echo] Launching Selenium standalone server.
     [echo] Selenium2 logs are being written to /var/www/opa/reports/selenium2.log.
     [echo] Waiting 15 seconds for Selenium standalone server (http://127.0.0.1:4444) to become available.
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
blt > tests:behat:execute:
     [exec] /var/www/opa/tests/behat/features/Examples.feature
@example

Feature: Web drivers
  In order to verify that web drivers are working
  As a user
  I should be able to load the homepage
With and without Javascript

  @javascript
  Scenario: Load a page with Javascript # features/Examples.feature:9
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 25721
Only local connections are allowed.
    Given I am on "/"                   # Drupal\DrupalExtension\Context\MinkContext::visit()
      Could not open connection: unknown error: Chrome failed to start: exited abnormally
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.13.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 60.18 seconds
      Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
      System info: host: 'local', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.7
.0_121'

      Driver info: org.openqa.selenium.chrome.ChromeDriver (Behat\Mink\Exception\DriverException)
    Then I should see the text "Log in"

@geerlingguy
Copy link
Owner

I haven't encountered this issue in a while, but I'll try to run some of my other site's tests in the VM soon to see what's going on. It sounds like a Chrome/chromedriver issue in 14.04, since I don't think I've seen the error in 16.04 lately.

@geerlingguy
Copy link
Owner

Linking #1122 - could this be related?

@subhojit777
Copy link
Contributor

subhojit777 commented Feb 9, 2017

I am also getting this error Could not open connection: chrome not reachable. My host machine is Mac OSX 10.12.2, and VM is Ubuntu 16.04. I have selenium and Java enabled under installed_extras. When I execute behat --profile=chrome I get this error:

    Given I am an anonymous user                                              # Drupal\DrupalExtension\Context\DrupalContext::assertAnonymousUser()
      Could not open connection: chrome not reachable
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.4.0-31-generic x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 114.36 seconds
      Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
      System info: host: 'drupalvm', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-31-generic', java.version: '1.8.0_121'
      Driver info: org.openqa.selenium.chrome.ChromeDriver (Behat\Mink\Exception\DriverException)

This is my behat.yml:

default:
  autoload:
    '': %paths.base%/tests/features/bootstrap
  suites:
    listjs_views:
      contexts:
        - ListjsContext
        - ListjsThemeContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\DrushContext
      paths:
        - %paths.base%/tests/features/listjs_theme.feature
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~
      browser_name: 'phantomjs'
      base_url: "http://listjs.drupalvm.dev/"
    Drupal\DrupalExtension:
      blackbox: ~
      region_map:
        theme_list_wrapper: '.mykittens'
      api_driver: 'drupal'
      drush_driver: 'drush'
      drush:
        root: "/var/www/drupalvm/listjs"
      drupal:
        drupal_root: "/var/www/drupalvm/listjs"
chrome:
  extensions:
    Behat\MinkExtension:
      javascript_session: 'selenium2'
      browser_name: 'chrome'
      show_cmd: "open %s"
      selenium2:
        wd_host: 'http://listjs.drupalvm.dev:4444/wd/hub'
        browser: 'chrome'

I have followed the docs, Acquia Blt code, this issue #367, I don't know what I am missing.

Noob question: I don't have to execute selenium from the host right? The VM will run the selenium, and we have to connect the selenium in VM to the host machine's Chrome browser, and it will open up the dialog.

Let me know if we can move this discussion to a separate issue.

FYI Only the tests with @javascript tag is not working.

@subhojit777
Copy link
Contributor

Updated DrupalVM to the latest release 4.2.1 -- still no :(

@subhojit777
Copy link
Contributor

BTW I am getting this error on provisioning:

fatal: [drupalvm]: FAILED! => {"changed": false, "cmd": "systemctl status selenium | grep \"active (running)\"", "delta": "0:00:00.007711", "end": "2017-02-09
 13:19:54.996325", "failed": true, "rc": 1, "start": "2017-02-09 13:19:54.988614", "stderr": "", "stdout": "", "stdout_lines": [], "warnings": []}

@geerlingguy
Copy link
Owner

@subhojit777 - Are you executing tests inside the VM? e.g. where are you running the behat command?

@subhojit777
Copy link
Contributor

@geerlingguy Yes, inside the VM. I am executing the behat command inside the VM.

@geerlingguy
Copy link
Owner

I wonder if this is due to some other recent change in BLT... @subhojit777 and @devert - Is this with projects built with BLT, or derived from the Behat setup used by BLT?

I have one project with BLT 8.6.6 running on Drupal VM 4.2.1, and I just ran a set of tests (both with and without @javascript tests), and it all worked fine (used blt tests:behat):

12 scenarios (12 passed)
82 steps (82 passed)
1m28.78s (75.84Mb)

I have another project with BLT 8.6.11 running on Drupal VM 4.2.1, and I just ran a set of tests, and got:

Current response status code is 403, but 200 expected. (Behat\Mink\Exception\ExpectationException)
...
1 scenario (1 failed)
3 steps (1 passed, 1 failed, 1 skipped)

But that seems like it's a different issue altogether... hrm, I haven't run the behat tests for this other project for a while, so I'll have to see what's going on.

@grasmash
Copy link

Various google searches suggest that this is the result of a version mismatch between chromedriver and selenium-server-standalone.

@geerlingguy
Copy link
Owner

In any case, it sounds like whatever the fix, it will need to be done in https://github.com/arknoll/ansible-role-selenium/issues

@geerlingguy
Copy link
Owner

geerlingguy commented Feb 13, 2017

Yay, I think I finally reproduced the error!

Feature: Home page
  In order to verify that the home page is working
  As a user
  I should be able to load the homepage
  With and without Javascript

  @javascript
  Scenario: Load a page with Javascript                   # features/Home Page.feature:8
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 27769
Only local connections are allowed.
    Given I am on "/"                                     # Drupal\DrupalExtension\Context\MinkContext::visit()
      Could not open connection: unknown error: Chrome failed to start: exited abnormally
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.13.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 60.28 seconds
      Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
      System info: host: 'local', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.7.0_121'
      Driver info: org.openqa.selenium.chrome.ChromeDriver (Behat\Mink\Exception\DriverException)

@geerlingguy
Copy link
Owner

Doing some debugging based on this SE answer, which suggests the problem is "a mismatch between the versions of chromedriver and selenium-server-standalone".

vagrant@local:/usr/bin$ ./chromedriver
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 9515
Only local connections are allowed.

So I'm using 2.27, which is the latest version of chromedriver according to http://chromedriver.storage.googleapis.com/LATEST_RELEASE (which the arknoll.selenium role uses to get the release version) and https://sites.google.com/a/chromium.org/chromedriver/downloads.

Next up, what Chrome version is available?

$ google-chrome --version
Google Chrome 56.0.2924.87

So that all seems well and good, and highly compatible. Next up, Selenium.

@geerlingguy
Copy link
Owner

geerlingguy commented Feb 13, 2017

Looks like selenium-server-standalone needs updating, maybe... http://www.seleniumhq.org/download/ says 3.0.1 is available. The role defaults to 2.53.0 currently. Going to test if this fixes it.

Test by adding selenium_version: "3.0.1" to your config.yml, then run vagrant provision.

@geerlingguy
Copy link
Owner

Still not sure what's going on... if I do the steps in the comment above, I'm still not able to get my tests to pass; it looks like Selenium is still picking up 2.53.1 somehow!

@geerlingguy
Copy link
Owner

PR against Selenium role here: arknoll/ansible-role-selenium#30

@geerlingguy
Copy link
Owner

oooooh... apparently The selenium version is locked into BLT at 2.53.0. So might need to be updated there as well!

@geerlingguy
Copy link
Owner

So...

composer require --dev se/selenium-server-standalone:^3.0

But now I realize Ubuntu 14.04 defaults to Java 7 (OpenSDK 1.7), so I'm getting:

blt > tests:selenium:launch:
blt > tests:selenium:kill:
     [echo] Killing any selenium processes that are already running.
     [echo] Launching Selenium standalone server.
     [echo] Selenium2 logs are being written to /var/www/chn1/reports/selenium2.log.
     [echo] Waiting 15 seconds for Selenium standalone server (http://127.0.0.1:4444) to become available.
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncherV3 : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
...
[phingcall] /var/www/chn1/vendor/acquia/blt/phing/tasks/tests.xml:128:8: /var/www/chn1/vendor/acquia/blt/phing/tasks/tests.xml:148:12: /var/www/chn1/vendor/acquia/blt/phing/tasks/tests.xml:151:18: Unable to start Selenium2 standalone server on http://127.0.0.1:4444/wd/hub.

BUILD FAILED/var/www/chn1/vendor/acquia/blt/phing/tasks/tests.xml:22:8: /var/www/chn1/vendor/acquia/blt/phing/tasks/tests.xml:25:26: Execution of the target buildfile failed. Aborting.
; 24.8082 seconds

Need to upgrade Java to 1.8 to get latest version of Selenium working, since requirements may have been bumped? Ugh.

@geerlingguy
Copy link
Owner

geerlingguy commented Feb 13, 2017

Manual steps to upgrade from OpenJDK 7 to OpenJDK 8 on Ubuntu 14.04:

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get purge -y openjdk*
sudo apt-get -y install openjdk-8-jdk

@geerlingguy
Copy link
Owner

Looking better so far:

blt > tests:selenium:launch:
blt > tests:selenium:kill:
     [echo] Killing any selenium processes that are already running.
     [echo] Launching Selenium standalone server.
     [echo] Selenium2 logs are being written to /var/www/chn1/reports/selenium2.log.
     [echo] Waiting 15 seconds for Selenium standalone server (http://127.0.0.1:4444) to become available.
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
Possible malformed URL: http://127.0.0.1:4444/wd/hub
2017-02-13 23:13:00.461:INFO::main: Logging initialized @5476ms
2017-02-13 23:13:00.711:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-02-13 23:13:00.752:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5034c75a{/,null,AVAILABLE}
2017-02-13 23:13:00.794:INFO:osjs.ServerConnector:main: Started ServerConnector@7c6acd84{HTTP/1.1}{0.0.0.0:4444}
2017-02-13 23:13:00.795:INFO:osjs.Server:main: Started @5811ms

@geerlingguy
Copy link
Owner

Yeah... but still no dice!

  @javascript
  Scenario: Load a page with Javascript                   # features/Home Page.feature:8
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 16415
Only local connections are allowed.
    Given I am on "/"                                     # Drupal\DrupalExtension\Context\MinkContext::visit()
      no such session
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.13.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 16 milliseconds
      Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
      System info: host: 'local', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version: '1.8.0_111'
      Driver info: org.openqa.selenium.chrome.ChromeDriver
      Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
        (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 3.13.0-32-generic x86_64), platform=ANY}]
      Session ID: 84d54b44794cb3f8509443db4eb60e97 (WebDriver\Exception\NoSuchDriver)

Now getting NoSuchDriver, which is at least better than the other exception, maybe?

@subhojit777
Copy link
Contributor

subhojit777 commented Feb 14, 2017

#1152 (comment) Re: No, it is not built using Blt.

Are you running Selenium and Chromedriver from host or inside VM?

@subhojit777
Copy link
Contributor

#1152 (comment) Re: After upgrading to Selenium 3.0.1, I am also getting the same error.

@subhojit777
Copy link
Contributor

However headless testing with PhantomJS is working alright, it is just that the steps mentioned here #421 are not working for me :\

I will be writing a documentation for this once it is setup in my machine. Currently the Selenium integration docs are scattered, which makes it hard to follow.

@thom8
Copy link
Collaborator

thom8 commented Feb 15, 2017

You may not need chromedriver/selenium if using PhantomJS.
It's a lot faster however it doesn't have the full capabilities.

This role can install and configure a PhantomJS webdriver on port 4444 so is effectively a drop in replacement for selenium.

Maybe something to include in DVM?

@subhojit777
Copy link
Contributor

subhojit777 commented Feb 15, 2017

I can continue with PhantomJS, but the documentation for taking screenshots was not working for me.

My goal is - Run Behat tests in my local (VM/host), and view the UI (for debugging).

That is all I need.

I know PhantomJS is fast, but I am inclined towards Chromedriver + Selenium because it allows better debugging than screenshots. I want to make full use of this step https://github.com/jhedstrom/drupalextension/blob/master/src/Drupal/DrupalExtension/Context/DrupalContext.php#L427 (Then (I )break)

@geerlingguy
Copy link
Owner

@thom8 - Very true. I'd recommend upgrading to Ubuntu 16.04 or CentOS 7 if possible instead, then. Or maybe just wait another month or so and a new Chromedriver and Chrome release may 'just work'.

@thom8
Copy link
Collaborator

thom8 commented Mar 8, 2017

@geerlingguy depends on the accuracy requirements of the tests, I prefer to run more tests more often in CI, and the speed difference it quite substantial.

However, we're still planning to run nightly builds with selenium to pick up any shortfall.

@thom8
Copy link
Collaborator

thom8 commented Mar 8, 2017

something like this works quite well in CI --

phantomjs --webdriver=4444 > /var/www/html/phantomjs.log 2>&1 & # Start phantomJS server
behat --tags ci --colors --stop-on-failure
pkill phantomjs # Kill phantomJS server

no JAVA required :)

@geerlingguy
Copy link
Owner

Opening this back up. We're taking a look at it at DrupalCon Baltimore.

@geerlingguy geerlingguy reopened this Apr 28, 2017
@marji
Copy link

marji commented Apr 28, 2017

problem still present in the below configuration on a Drupal VM:

  • Ubuntu 16.04
  • selenium-server-standalone-3.4.0.jar
  • Google Chrome 58.0.3029.81
  • ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5) (which says it Supports Chrome v56-58)

This is how it looks like process wise:

root     22429 31085  2 18:47 ?        00:00:00 /usr/bin/chromedriver --port=26886
root     22434 22429  0 18:47 ?        00:00:00 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.Hiwyyh/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12370 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.V94xRx data:,
root     22444 22434  0 18:47 ?        00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.org.chromium.Chromium.V94xRx
root     22446 22444  0 18:47 ?        00:00:00 /opt/google/chrome/nacl_helper
root     22450 22444  0 18:47 ?        00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.org.chromium.Chromium.V94xRx

root     31068     1  0 17:44 ?        00:00:00 /bin/sh /usr/bin/xvfb-run /usr/bin/java -client -jar /opt/selenium/selenium-server-standalone-3.4.0.jar
root     31085 31068  0 17:44 ?        00:00:10 /usr/bin/java -client -jar /opt/selenium/selenium-server-standalone-3.4.0.jar

This is the error:
Could not open connection: chrome not reachable
Details:

  @javascript
  Scenario: Ensure that the home page is accessible by anonymous user # tests/behat/home_page.feature:7
    Given I am an anonymous user                                      # Drupal\DrupalExtension\Context\DrupalContext::assertAnonymousUser()
      Could not open connection: chrome not reachable
        (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-75-generic x86_64) (WARNING: The server did not provide any stacktrace information)
      Command duration or timeout: 114.32 seconds
      Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
      System info: host: 'drupalvm', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-75-generic', java.version: '1.8.0_121'
      Driver info: driver.version: ChromeDriver (Behat\Mink\Exception\DriverException)

And this is the defunct chrome after the above error happens:

root     22429 31085  0 18:47 ?        00:00:01 /usr/bin/chromedriver --port=26886
root     22434 22429  0 18:47 ?        00:00:00 [chrome] <defunct>

@geerlingguy
Copy link
Owner

@marji - Thanks for confirming! It seems we still have yet to find the magical combination of chromedriver + chrome + behat drupal extension versions to make this work :/

@generalconsensus
Copy link

@geerlingguy @marji I ran it through it's paces on Selenium 3.3.1 and 3.4, Chromedriver 2.28, and Chromedriver 2.22. All connection refused. I added my debug information as this appears to be a Chrome issue here: https://bugs.chromium.org/p/chromium/issues/detail?id=716175&can=2&start=0&num=100&q=chromedriver&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified&groupby=&sort=

@geerlingguy
Copy link
Owner

Opened another upstream issue for tracking purposes here: jhedstrom/drupalextension#370

I'm going to see if there's anything more I can do today, but I'm focused on a couple other issues at the moment, don't want to fork my brain too badly today!

@thom8
Copy link
Collaborator

thom8 commented Apr 29, 2017

Has anyone tried headless chrome?

@geerlingguy
Copy link
Owner

@thom8 - I think the last time @grasmash looked into it, it seemed there had been no real activity there yet. All the layers would need to support it (selenium/behat, basically), right?

@thom8
Copy link
Collaborator

thom8 commented Apr 29, 2017

Not sure but PhantomJS is no longer going to be maintained -- https://www.drupal.org/node/2869424

https://www.chromestatus.com/features/5678767817097216

@geerlingguy
Copy link
Owner

@thom8 - Yeah 😢 — thus I've re-opened this issue, since PhantomJS is probably not the best long-term workaround anymore.

@AlexSkrypnyk
Copy link

AlexSkrypnyk commented Apr 30, 2017

A workaround script with 100% compatible versions is below. Also, the same versions running successfully in Circle CI https://github.com/integratedexperts/behat-relativity/blob/master/circle.yml

#!/bin/sh
#
# Install Selenium, xvfb, Chrome and Chromedriver
#
#=========================================================
SELENIUM_URL=https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
CHROMEDRIVER_URL=http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip
#=========================================================

cd /var/tmp

#=========================================================
echo "Install the packages..."
#=========================================================
sudo apt-get update
sudo apt-get -y install fluxbox xorg default-jre rungetty xvfb gtk2-engines-pixbuf xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable imagemagick x11-apps

#=========================================================
echo "Download latest Selenium server..."
#=========================================================
wget $SELENIUM_URL -O selenium-server-standalone.jar
chown vagrant:vagrant selenium-server-standalone.jar

#=========================================================
echo "Download the latest Chrome..."
#=========================================================
wget "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo rm google-chrome-stable_current_amd64.deb
sudo apt-get install -y -f

#=========================================================
echo "Download latest chromedriver..."
#=========================================================
wget $CHROMEDRIVER_URL
unzip chromedriver_linux64.zip
sudo rm chromedriver_linux64.zip
chown vagrant:vagrant chromedriver

#=========================================================
echo "Apply workaround for Chrome..."
#=========================================================
# Make Chrome run with additional flags to resolve content scaling issues.
echo '#! /bin/bash' | sudo tee /opt/google/chrome/google-chrome-hack
echo '/opt/google/chrome/google-chrome --high-dpi-support=1 --force-device-scale-factor=1' | sudo tee --append /opt/google/chrome/google-chrome-hack
sudo chmod 755 /opt/google/chrome/google-chrome-hack
sudo mv /usr/bin/google-chrome-stable /usr/bin/google-chrome-stable.backup
cd /usr/bin && sudo ln -s /opt/google/chrome/google-chrome-hack google-chrome-stable

@thom8
Copy link
Collaborator

thom8 commented Apr 30, 2017

Thanks @alexdesignworks

Another option could be to include a role which installs docker then you'd be able to use docker selenium which is maintained by Selenium.

This includes many prebuilt and more importantly pretested images -- https://github.com/SeleniumHQ/docker-selenium#docker-images-for-selenium-standalone-server-hub-and-node-configurations-with-chrome-and-firefox

Maybe a geerlingguy.docker role?

@geerlingguy
Copy link
Owner

@thom8 - ... it does exist :D https://galaxy.ansible.com/geerlingguy/docker/

The question would be then, would it be best to work on moving @arknoll 's role to use the docker container and depend on Docker being available? Or should I create a new selenium role that just uses the docker container?

(Mostly that's a question to @arknoll about whether he'd like to keep his role more or less as-is, or whether he'd be okay with maybe switching to the container in a new major version... one problem is it would be practically impossible to getting such a setup working in CentOS, and probably Ubuntu 12.04 (which is technically no longer supported anyways)).

@thom8
Copy link
Collaborator

thom8 commented Apr 30, 2017

@geerlingguy nice!

Selenium is inside these containers so you only need to run it on port 4444.

Note that you can use docker selenium now if you run docker/selenium/behat from your host machine, the difficulty would be using the drush driver from the host.. wonder if it supports aliases?

also no JAVA required :)

@geerlingguy
Copy link
Owner

@geerlingguy
Copy link
Owner

I'd like to switch all the docs and examples to use Chrome in --headless mode (Chrome 59 and later) since it seems that's the most consistent and reliable approach now. See my notes in closing #1342, and see the changes Acquia's BLT implemented to get it working for Behat: acquia/blt#1705

It looks like the changes we need to make are:

  • Require dmore/behat-chrome-extension
  • Set Chrome's default port as 9222
  • Update the behat.yml parameters:
    • browser_name: chrome
    • javascript_session: default

Read through the rest of the PR linked above for more specific changes.

@gollyg
Copy link

gollyg commented Jun 29, 2017

I encountered the same problem, but seemed to be able to resolve it without changing the configuration for Drupal VM. I am using 8.x of BLT with DrupalVM installed via BLT.

Changing the robo command thats launches selenium to use xvfb-run seems to solve it.

->execute("xvfb-run " . $this->getConfigValue('composer.bin') . "/selenium-server-standalone -port 4444 -log {$this->seleniumLogFile}  > /dev/null 2>&1")

This also requires an extra line in the killSelenium() method to clean up xvfb after running:

$this->getContainer()->get('executor')->killProcessByName('Xvfb');

Going to run a few more checks and then look at submitting a patch to BLT.

[edit] Although it may be preferable to keep the robo task consistent and address the issue as indicated in the previous comment

@johnatasjmo
Copy link

@geerlingguy how to

Set Chrome's default port as 9222

Trying to set this up without BLT using chrome --headless mode

@ArtuGit
Copy link

ArtuGit commented Aug 22, 2017

I tried dmore/behat-chrome-extension with such settings:

myapp:
  extensions:
    Drupal\DrupalExtension:
      drupal:
        # Site docroot inside Docksal.
        drupal_root: /srv/myapp/docroot
      drush:
        # Site docroot inside Docksal.
        root: /srv/myapp/docroot
    DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
    Behat\MinkExtension:
        browser_name: chrome
        base_url: http://localhost
        sessions:
            default:
                chrome:
                    api_url: "http://localhost:9222"

Do you have any suggestions?

@thom8
Copy link
Collaborator

thom8 commented Aug 23, 2017

@geerlingguy
Copy link
Owner

I'm going to close this particular issue as I think it's been beaten to death. Further work can be managed through this feature request ticket: #1598

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests