geerlingguy / drupal-vm

A VM for Drupal development
https://www.drupalvm.com/
MIT License
1.37k stars 645 forks source link

Behat @javascript tests aren't working #1342

Closed ArtuGit closed 7 years ago

ArtuGit commented 7 years ago

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

ArtuGit commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

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

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

ArtuGit commented 7 years ago

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 commented 7 years ago
vagrant@drupalvm:/var/www/drupalvm/drupal/web$ ping test7.drupalvm.dev:4444
ping: unknown host test7.drupalvm.dev:4444
thom8 commented 7 years ago

@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 commented 7 years ago

Also, if trying to use Chromedriver with Chrome, please see: https://github.com/geerlingguy/drupal-vm/issues/1152 :(

attheshow commented 7 years ago

I think I might have the same issue here.

Issue Type

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

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 commented 7 years ago

I'm going to close this issue and push further discussion over to https://github.com/geerlingguy/drupal-vm/issues/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: https://github.com/acquia/blt/pull/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 commented 7 years ago

It looks like the changes we need to make are:

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

ArtuGit commented 7 years ago

@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 commented 7 years ago

@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