1

I am trying to setup behat tests with Selenium and Chromedriver for my D8 project.

All @api tests work perfectly, but as soon as I add @javascript, it stops working with

Behat\Testwork\Call\Exception\FatalThrowableError: Fatal error: Call to a member function elements() on null in vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:488

My Behat.yml

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
 extensions:
   Behat\MinkExtension:
     goutte: ~
     javascript_session: 'selenium2'
     browser_name: 'chrome'
     selenium2:
       wd_host: 'http://192.168.56.1:5555/wd/hub'
     base_url: http://mydev.dev
   Drupal\DrupalExtension:
     api_driver: "drupal"
     blackbox: ~
     drush:
       root: "/usr/share/drush"
     drupal:
       drupal_root: "/var/www/mydev"

It is important to note that i am running inside a vagrant box and that I am also running my behat tests from within the vagrant box using:

bin/behat -v -c behat.yml features/my_feature/

My current feature just contains:

@api @javascript
Feature: Create a Quiz
In order to have a quiz on my site, as a Content Editor, I need to be 
able to create one

Scenario: Create a quiz
  Given I am logged in as a user with the "administrator" role
  And I go to "node/add/quiz"
  #Then show last response

I have registered a node on my local machine (host) to the selenium hub within the vagrant. I have also validated that http://192.168.56.1:5555/wd/hub/ is working just fine.

Thanks in advance

  • Just a question, but are you running with BigPipe enabled? I found that to interfere with certain tests. – Kevin Aug 23 '17 at 16:01
1

It turned out to be a bug in the Drupal extension that is fixed here: https://github.com/jhedstrom/drupalextension/pull/379

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.