I am just getting started with BeHat and I'm able to successfully run tests that do not require authentication. But, anything that requires authentication is failing.

STATEMENT (or any logged in statement)

Fails with ERROR MESSAGE .

But, if I add 'not-logged-in' as a possible class for logged in, then the test passes. This tells me that I am not successfully logging in with my tests. The test is actually finding a class 'not-logged-in' when it is testing to see if it's logged in.

I am getting email notification that a user has been created when the test runs. So, I know that a user is being created, but not successfully logging in.

Feature: Authentication
  In order to make sure Behaviour testing is working
  As a behat test user
  I want to make sure I can log in

  Scenario: Anonymous access   
    Given I am on the homepage 
    Then I should see "Login" 

  Scenario: Test Being Logged In
    Given I am logged in as a user with the "administrator" role
    Then I should see the link "Test Link"

My behat.yml file looks like this:

        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
      goutte: ~
      selenium2: ~
      base_url: http://mysite.localhost
      blackbox: ~
      api_driver: 'drupal' 
        alias: 'local'
        drupal_root: '/Users/myfolder/sites/mysite' 
        footer: "#footer"

1 Answer 1


As mentioned in my question, it was pretty clear that Behat was failing to login, so I began to look for modules that might interfere with the login process.

It turns out that we are using the module AntiBot (https://www.drupal.org/project/antibot) and when we disabled this module, we were able to run tests that involved successfully logging into Drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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