-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use better technique to determine whether user is logged in #131 #237
Conversation
Any idea how much work it would be to add the D8-logic to the Drupal Drivers, and use that here (I assume it would not require making the redundant page load)? |
Use better technique to determine whether user is logged in #131
Thanks for this! |
Thanks for this. Now it seems I just have to use yesterdays git release. :-} Goody, I guess. (++ works for me BTW!) |
++ thank you for this |
++ thank you for this! phantomjs was breaking because of the loggedIn() function |
@jhedstrom @LionsAd Due to the inherent complexity of upgrading Behat to the latest dev release to be able to benefit from this functionality, would it be possible to patch earlier versions with this? Like say 1.0? |
@generalconsensus I'd certainly review a PR for this fix against 1.x. |
@jhedstrom Thanks! Here is the P.R. #247 |
Based heavily on #131
This makes Drupal 7 work for themes without logout link on front-page and also makes Drupal 8 minimal profile, which uses stark work.
For most cases it can also avoid the visit to an additional page, which is great.
Original report
Not all websites have the logout link on the front page, in my case, Chrome with Selenium was simply to fast, admin-menu showed up after the check for the link happened.
Since there is no real 100% reliable method in D7, I've implemented two more methods to determine if a user is logged in. (D8 has the user information in the global Drupal Javascript object)
First test: Check for a "logged-in" class on the body element, most themes support this. (Mothership for example doesn't)
Second test: Visit "/user/login", if there is no login form, the user should be logged in.
I also had the Idea to simple check "/user/login" for a 403 status code, but this is not supported by Selenium because it is out of scope. (https://code.google.com/p/selenium/issues/detail?id=141)