I have the Email Registration module enabled in Drupal 8.
When I try
"Given I am logged in as a user with the "authenticated user" role
Then I get the following error:
Form field with id|name|label|value|placeholder "Username" not found. (Behat\Mink\Exception\ElementNotFoundException)
This is because the username field is hidden when the Email Registration module is enabled. So I need to override this to not look for a username field if Email Registration is enabled, but I'm not sure how to go about this. Any pointers would be much appreciated.
Comments
Comment #2
generalconsensus commentedYou should be able to locally patch your system with this commit: https://github.com/jhedstrom/drupalextension/pull/237.
This patch allows you to set class selectors to help make sure that the assertion for checking if a user is logged in is working correctly
Comment #3
samgao commentedPlease see: https://www.drupal.org/node/2145691#comment-9946699
Just add username_field: "E-mail" in behat.yml, it could be "E-mail or username" or "Email" depending on what label it is on your login page.
Comment #4
willhallonlineI would agree with @samgao #3. This can probably be closed as "works as designed"?
Comment #5
pfrenssenChanging the selector of the username field will not be enough, this will cause the field to be found, but the username will still be filled in instead of the e-mail address. This will fail form validation.
There is a solution in progress for the upcoming 4.x release of DrupalExtension which will allow to swap out the authentication mechanism with custom code. This will allow Email Registration to work, but also any other non-standard authentication such as SSO, CAS or Facebook Connect.
See issue #339 on Github to follow the progress.
Comment #6
pfrenssenThere is an initial version available of the PR on Github I linked in my previous comment.
I've now also made an issue in Email Registration to provide their part of the integration: #2843505: [2.x] Add support for Behat tests. An initial version is also available but it still needs test coverage.
You can try this out by applying the patch for Email Registration and checking out the PR for BDE.
Comment #7
dremy commentedAdding a minor temporary patch to fix for email registration.
Comment #8
abh.ai commentedTemporary patch for only Email ID placeholder.
Comment #9
rolki commentedPlease, follow this flow:
Paste this into the `composer.json` file
Into your behat.yml file paste this one:
Comment #10
rolki commentedComment #11
gregglesFor what it's worth, I think this is a duplicate of #2843505: [2.x] Add support for Behat tests.
Comment #12
pfrenssenYes this is a duplicate of #2843505: [2.x] Add support for Behat tests which has a patch. On the DrupalExtension side this has been fixed in the 4.0 release where we provide the AuthenticationManager service which can be swapped out for custom implementations (as demonstrated in the patch for the other issue).