Behat @javascript test can not login user - incorrect username or password message I am running:


Drupal 7
Behat 3.5.0
Selenium 3.5.0
Chrome Driver 73.x


Using this test:

Feature: User Profile

Background:
  Given users:
    | name | status | roles |
    | incomplete | 1 | authenticated user |
    | complete | 1   | authenticated user |

  Given profiles:
    | drupal_username | field_profile_completed:value | field_first_name | field_last_name | field_birth_month | field_birth_day | field_degree | field_profession | field_specialty | field_organization | field_department |
    | incomplete | 0                                  | |  |  |  |  |  |  |  |  |
    | complete   | 1                                  | John | Doe | 08 | 03 | APRN | 15 | Anesthesiology | MyOrganization | MyDepartment |

@api
@noEncrypt
@defaultRegistration
@javascript
Scenario: As a user with an incomplete profile I should NOT see an icon indicating my profile is not complete.
  Given I am logged in as complete
  Then I should not see an ".js--user-profile-incomplete" element

@api
@noEncrypt
@defaultRegistration
@javascript
Scenario: As a user with an incomplete profile I should see an icon indicating my profile is not complete.
  Given I am on "/user/login"
  And I fill in the following:
    | name | incomplete|
    | pass | password |
  And press "edit-submit"
  Then I should be on "/"
  Then I should see an ".js--user-profile-incomplete" element
  When I wait for ".profile-notify__incomplete"
  Then I should see an ".profile-notify__exclamation" element


As you can see, I've tried  logging in using Given I am logged in as and tried logging in via a meta-step.  I can watch it in the browser and I'm getting an "Unrecognized username or password" error.

Login works fine without @javascript but I can't test the "When I wait" functionality.  If I use a break I can see that the users are created in the database.

Why are my @javascript tests not able to login?
It was a pain to track down but I traced it to the Security module.  It encrypts the password field on form submit - disabling the module allows Behat @javascript tests to run fine.