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

Behat @javascript tests aren't working #1342

Closed
ArtuGit opened this issue Apr 25, 2017 · 13 comments
Closed

Behat @javascript tests aren't working #1342

ArtuGit opened this issue Apr 25, 2017 · 13 comments
Labels

Comments

@ArtuGit
Copy link

ArtuGit commented Apr 25, 2017

I have Drupal VM 4.4.5 with ubuntu1404.
I made an upgrade from DVM 4.4.4 then I did vagrant provision a couple times.
I used this manual to establish Behat - http://docs.drupalvm.com/en/latest/extras/selenium/ .

When I run a behat scenario with @javascript I get following:

      Could not open connection: Curl error thrown for http POST to http://test7.drupalvm.dev:4444/wd/hub/session with params: {"desiredCapabilities":{"tags":["drupalvm","PHP 5.6.30-10+deb.sury.org~trusty+2"],"browser":"firefox","ignoreZoomSetting":false,"name":"Behat feature suite","browserName":"firefox"}}
      
      Failed to connect to test7.drupalvm.dev port 4444: Connection refused (Behat\Mink\Exception\DriverException)

I read some issues about such problem but I can not find a solution.

  1. Why the port 4444 is failed? It is on firewall_allowed_tcp_ports:`.
  2. Why does it try to run firefox? I read now Chrome should work.

Regards, Artu

@geerlingguy geerlingguy changed the title Behat does not work with @javascript Behat @javascript tests aren't working Apr 25, 2017
@ArtuGit
Copy link
Author

ArtuGit commented Apr 25, 2017

I see the only working solution now is using of PhantomJS as a browser for Mink.
How can I setup it?

I included phantomjs to nodejs_npm_global_packages.
What should I do further?

Why does it fail to connect to port 4444?

@geerlingguy
Copy link
Owner

@ArtuGit - Are you running the behat commands inside the VM or on the host? If so, it wouldn't be able to connect through to port 4444 since that's meant to only be accessed inside Drupal VM.

Also, can you share what you have set up in your behat.yml.

@ArtuGit
Copy link
Author

ArtuGit commented Apr 26, 2017

@geerlingguy
Of course, I am running it inside DVM.

My project behat.yml:

default:
  suites:
    web_features:
      paths: [ %paths.base%/features/web ]
      contexts:
        - WebContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      javascript_session: selenium2
      selenium2:
        wd_host: http://test7.drupalvm.dev:4444/wd/hub
      base_url: http://test7.drupalvm.dev
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drupal'
      drupal:
        drupal_root: '/var/www/drupalvm/test7/web'
      region_map:
        content: "#content"

@thom8
Copy link
Collaborator

thom8 commented Apr 26, 2017

@ArtuGit can you try ping test7.drupalvm.dev inside the VM.

sometimes it's easier to use use http://localhost:4444/wd/hub

@ArtuGit
Copy link
Author

ArtuGit commented Apr 26, 2017

It works (inside DVM):

vagrant@drupalvm:/var/www/drupalvm/drupal/web$ ping test7.drupalvm.dev
PING test7.drupalvm.dev (192.168.88.88) 56(84) bytes of data.
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=3 ttl=64 time=0.025 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=4 ttl=64 time=0.031 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=5 ttl=64 time=0.026 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=6 ttl=64 time=0.026 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=7 ttl=64 time=0.027 ms
64 bytes from drupalvm.dev (192.168.88.88): icmp_seq=8 ttl=64 time=0.026 ms

@ArtuGit
Copy link
Author

ArtuGit commented Apr 26, 2017

vagrant@drupalvm:/var/www/drupalvm/drupal/web$ ping test7.drupalvm.dev:4444
ping: unknown host test7.drupalvm.dev:4444

@thom8
Copy link
Collaborator

thom8 commented Apr 26, 2017

@ArtuGit please post more information about your configuration, sounds like selenium isn't setup correctly.

See the issue template -- https://github.com/geerlingguy/drupal-vm/blob/master/.github/ISSUE_TEMPLATE

@geerlingguy
Copy link
Owner

Also, if trying to use Chromedriver with Chrome, please see: #1152 :(

@attheshow
Copy link

I think I might have the same issue here.

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 1.9.3
VirtualBox 5.1.18r114002
ansible 2.2.2.0
  config file = 
  configured module search path = Default w/o overrides

Your OS

  • macOS (10.12.4)

Full console output

config.yml - https://gist.github.com/attheshow/c8f8cb2a932c68e254557172d5d0b125
behat.yml - https://gist.github.com/attheshow/c375e715c50cc620915eaddd6d9e4e46
SolrSearch.feature - https://gist.github.com/attheshow/aaca463278bd9ea421aef1de245531c1
output of behat - https://gist.github.com/attheshow/22c49f01d10097b02cb3a2e027838b33

Summary

Unable to run a @javascript Behat test, unable to ping on port 4444 when logged into the VM. Already tried vagrant destroy && vagrant up without success.

@geerlingguy
Copy link
Owner

I'm going to close this issue and push further discussion over to #1152

Now that Chrome has a headless mode, PhantomJS seems to be going the way of the dodo bird, and all the various webdrivers are in states of brokenness, I'm going to start pushing everyone towards using Google Chrome's headless mode first, and then hopefully also have a solution that uses FireFox.

PhantomJS seems to still work in most cases, but is more difficult to get set up, and also seems to be less efficient than Chrome.

See downstream implementation in Acquia's BLT project: acquia/blt#1705

I would like to test things out standalone inside Drupal VM (with a default Drupal 8 website), and rework the documentation to support this use case.

@geerlingguy
Copy link
Owner

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 in the comment above for more specific changes.

@ArtuGit
Copy link
Author

ArtuGit commented Aug 20, 2017

@geerlingguy
Could give the answer: Is this issue solved or not now?

I see a bunch of issues around this topic, but I do not see a specific solution

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

What did you mean?

Do you have an example of specific configuration anywhere?

@bnagaonkar
Copy link

bnagaonkar commented Aug 30, 2017

@ArtuGit This fixes the issue for me

    Behat\MinkExtension:
        browser_name: 'chrome'
        goutte: ~
        javascript_session: selenium2
        base_url: http://local.premiumtom.com
        files_path: /home/leo/repos/premium-tom/private
        selenium2:
          wd_host: http://localhost:4444/wd/hub
          browser: chrome
          capabilities: { "browser": "chrome", "version": "*", 'chrome': {'switches':['--start-maximized', "--headless", "--disable-gpu"]}}

adding --headless for chrome

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

No branches or pull requests

5 participants