I'm trying to use Behat and Drupal for BDD, but I'm running into some authentication issues. Simple steps like:

Given I am logged in as a user with the "administrator" role

Fail because I'm using Drupal's CAS module, which essentially customizing the /user/login page. Any idea on how I can get past custom login pages with Behat?

2 Answers 2


You can test login form in this way:

When I visit 'user/login'
And I fill in "username" for "name"
And I fill in "userpass" for "pass"
And I press the "Log in" button
Then I should see the text "some text"

I was able to figure it out. You have to make sure the "Make CAS login default on login forms" option in the CAS settings is not checked and don't have "user" page under the "Specific pages" redirect. I still need to figure out how to disable these options through Behat, instead of manually, then my tests will truly be automated. I will post a reply once I figure it out.

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.