Skip to content
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

Log-in step occasionally fails. #47

Open
stephenharris opened this Issue Feb 17, 2017 · 16 comments

Comments

Projects
None yet
3 participants
@stephenharris
Copy link
Collaborator

stephenharris commented Feb 17, 2017

The "Given I am logged in as an " test scenario occasionally fails on Travis-CI with a "The user could not be logged-in" error.

Expected behavior

That the test passes all the time.

Current behavior

The test fails occasionally. No pattern has been observed yet.

Known failing instances:

Link WP PHP Driver
https://travis-ci.org/stephenharris/behat-wordpress-extension/jobs/202793337 4.7.2 5.6 wpapi
https://travis-ci.org/paulgibbs/behat-wordpress-extension/jobs/205790372 4.7.2 5.6 wpcli
https://travis-ci.org/paulgibbs/behat-wordpress-extension/jobs/205790376 4.7.2 7.1 wpcli
https://travis-ci.org/paulgibbs/behat-wordpress-extension/jobs/206945238 4.7.2 7.1 wpcli

Steps to reproduce (for bugs)

The failure happens occasionally. Let's use the above table to identify instances.

@stephenharris stephenharris added the bug label Feb 17, 2017

@stephenharris

This comment has been minimized.

Copy link
Collaborator Author

stephenharris commented Feb 17, 2017

This isn't new: stephenharris/WordPressBehatExtension#10

The problem appears to be the same. I can't find the screenshot of an instance of this bug, but it too showed the password entered into the username field.

@paulgibbs paulgibbs added this to the Future Release milestone Feb 18, 2017

@stephenharris stephenharris referenced this issue Mar 2, 2017

Merged

Fix "I am viewing post" step #64

6 of 9 tasks complete

paulgibbs added a commit that referenced this issue Mar 6, 2017

Rework `login()` method
Try to fix a bug with Behat entering both user/password into username field
by explicitly setting focus on the fields before entering values.

See #47

@paulgibbs paulgibbs referenced this issue Mar 6, 2017

Merged

Rework `login()` method #68

3 of 9 tasks complete
@stephenharris

This comment has been minimized.

Copy link
Collaborator Author

stephenharris commented Mar 20, 2017

Still happening occasionally. Here's a screenshot from my fork:

user-8

@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Mar 21, 2017

This is pretty crazy.

@paulgibbs paulgibbs referenced this issue Apr 30, 2017

Merged

Driver interface refactor #79

4 of 8 tasks complete

paulgibbs added a commit that referenced this issue May 24, 2017

Try improvements to the log-in step.
For unknown reasons, Behat/Mink seems to have problems logging into WordPress on an occassional and intermittent basis. A common failure is that Mink does not enter the username or password into the correct elements on the log-in form, or leaves one blank.

We've iterated fixes several times -- some environment specific, e.g. Travis-CI -- and this commit spins the wheel once more.

My local testing, and on Travis-CI, suggests this change improves the reliability of entering data into the log-in form. The idea is clearing the field values prior to data entry works around some sort of quirk in WebDriver/Selenium.

See #47.
@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Feb 7, 2018

Issue still exists for me when running tests locally or using Circle.CI.

@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Feb 7, 2018

It appears that I am getting log in error:

<div id="login_error">	<strong>ERROR</strong>: Invalid username. <a href="http://guwordpress.docksal/wp-login.php?action=lostpassword">Lost your password?</a><br></div>
@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Feb 7, 2018

There is definitely something wrong going on with setValue() method in logIn(). I called getValue() right after setValue() and it appears that the value is set improperly: a username is corrupted: in instead of myadmin, and empty string instead of a password.

@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Feb 7, 2018

@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Feb 8, 2018

Adding extra setValue() fixed the problem, but this issue seems really weird!

Here is my patch:

diff -ur behat-wordpress-extension/src/Context/Traits/UserAwareContextTrait.php behat-wordpress-extension-patched/src/Context/Traits/UserAwareContextTrait.php
--- behat-wordpress-extension/src/Context/Traits/UserAwareContextTrait.php      2018-02-07 18:27:56.000000000 -0500
+++ behat-wordpress-extension-patched/src/Context/Traits/UserAwareContextTrait.php      2018-02-07 18:27:48.000000000 -0500
@@ -39,6 +39,7 @@
         }
         $node->setValue('');
         $node->setValue($username);
+        $node->setValue($username);

         $node = $page->findField('user_pass');
         try {
@@ -48,6 +49,7 @@
         }
         $node->setValue('');
         $node->setValue($password);
+        $node->setValue($password);

         $page->findButton('wp-submit')->click();
@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Feb 8, 2018

@paulgibbs just saw your comment. I tried to alter all tests with a background condition to load homepage first, but that didn't affect on the log in errors. Hope it helps.

@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Feb 8, 2018

@dealancer dealancer referenced this issue Feb 9, 2018

Merged

Fix setting value in log in step #186

3 of 9 tasks complete

paulgibbs added a commit that referenced this issue Feb 14, 2018

Merge pull request #186 from dealancer/loginfail
Latest attempt at fixing log-in step glitches.

See #47
@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Feb 14, 2018

I've decided to merge it. I couldn't break it on Travis-CI, and I don't think it will hurt. I suspect whatever the very first step is, it might be occasionally prone to similar glitching, but without understanding the root cause more somehow, I've no better idea at the moment. :)

@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Feb 21, 2018

Unsurprisingly, the latest commit here does not fix this problem. It lives on!

paulgibbs added a commit that referenced this issue May 2, 2018

Fix null session when first step asserts a login
Brought in from Drupal Extension: jhedstrom/drupalextension#379

Hoping this might help address #47

paulgibbs added a commit that referenced this issue May 2, 2018

Fix null session when first step asserts a login
Brought in from Drupal Extension: jhedstrom/drupalextension#379

See #201
I'm hoping this might help address #47
@dealancer

This comment has been minimized.

Copy link
Contributor

dealancer commented Jun 11, 2018

@paulgibbs it looks like this issue still exists. It does not happen quite often, but for a large amount of tests, it happens nearly in 30% of runs of test suites.

@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Jun 11, 2018

@paulgibbs paulgibbs referenced this issue Feb 26, 2019

Merged

Add login page object #230

4 of 9 tasks complete
@paulgibbs

This comment has been minimized.

Copy link
Owner

paulgibbs commented Feb 26, 2019

Latest attempted fix (with JS) and more information about the potential bug in Mink is detailed in #230.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.