Skip to content
This repository has been archived by the owner. It is now read-only.

Log-in step occasionally fails. #47

Closed
stephenharris opened this issue Feb 17, 2017 · 18 comments
Closed

Log-in step occasionally fails. #47

stephenharris opened this issue Feb 17, 2017 · 18 comments
Labels

Comments

@stephenharris
Copy link
Collaborator

@stephenharris 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
Copy link
Collaborator Author

@stephenharris 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 mentioned this issue Mar 2, 2017
6 of 9 tasks
paulgibbs added a commit that referenced this issue Mar 6, 2017
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 mentioned this issue Mar 6, 2017
3 of 9 tasks
@stephenharris
Copy link
Collaborator Author

@stephenharris stephenharris commented Mar 20, 2017

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

user-8

@paulgibbs
Copy link
Owner

@paulgibbs paulgibbs commented Mar 21, 2017

This is pretty crazy.

@paulgibbs paulgibbs mentioned this issue Apr 30, 2017
4 of 8 tasks
paulgibbs added a commit that referenced this issue May 24, 2017
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.
@ghost
Copy link

@ghost ghost commented Feb 7, 2018

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

@ghost
Copy link

@ghost ghost 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>
@ghost
Copy link

@ghost ghost 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
Copy link
Owner

@paulgibbs paulgibbs commented Feb 7, 2018

@ghost
Copy link

@ghost ghost 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();
@ghost
Copy link

@ghost ghost 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
Copy link
Owner

@paulgibbs paulgibbs commented Feb 8, 2018

@ghost ghost mentioned this issue Feb 9, 2018
3 of 9 tasks
paulgibbs added a commit that referenced this issue Feb 14, 2018
Latest attempt at fixing log-in step glitches.

See #47
@paulgibbs
Copy link
Owner

@paulgibbs 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
Copy link
Owner

@paulgibbs 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
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
Brought in from Drupal Extension: jhedstrom/drupalextension#379

See #201
I'm hoping this might help address #47
@ghost
Copy link

@ghost ghost 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
Copy link
Owner

@paulgibbs paulgibbs commented Jun 11, 2018

@paulgibbs paulgibbs mentioned this issue Feb 26, 2019
4 of 9 tasks
@paulgibbs
Copy link
Owner

@paulgibbs paulgibbs commented Feb 26, 2019

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

@paulgibbs
Copy link
Owner

@paulgibbs paulgibbs commented May 15, 2019

paulgibbs added a commit that referenced this issue May 15, 2019
… session.

We believe this to be a cause of form field manipulation intermittently
failing, causing the log-in step to fail -- as "Given I am logged in as a user"
is often the the first line in a scenario!

See Behat/MinkExtension#286

This is the latest attempt in a long line of fixes to make Behat user log-in
reliable. See #47 for the history.
@paulgibbs
Copy link
Owner

@paulgibbs paulgibbs commented May 31, 2019

Going to close this for now -- #247 is the latest stab. Will re-open if it is still not more reliable etc.

@paulgibbs paulgibbs closed this May 31, 2019
@paulgibbs paulgibbs removed this from the Future Release milestone May 31, 2019
paulgibbs added a commit that referenced this issue Oct 20, 2019
… session.

We believe this to be a cause of form field manipulation intermittently
failing, causing the log-in step to fail -- as "Given I am logged in as a user"
is often the the first line in a scenario!

See Behat/MinkExtension#286

This is the latest attempt in a long line of fixes to make Behat user log-in
reliable. See #47 for the history.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants