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

$I->loginAsAdmin() always fails on travis-ci #121

Closed
rahularyan opened this issue Jan 6, 2018 · 11 comments
Closed

$I->loginAsAdmin() always fails on travis-ci #121

rahularyan opened this issue Jan 6, 2018 · 11 comments
Assignees
Labels

Comments

@rahularyan
Copy link

Hello,
Build always fails whenever I use $I->loginAsAdmin() in travis-ci. Not just travis, it happens in localhost but less frequently.

In chrome I noticed that framework is trying to fill username field too early. If username is admin then I see only in is filled.

To solve the issue I just added 3 seconds of wait and everything looks good now.

$I->amOnPage('/wp-login.php');
$I->wait(3);
$I->submitForm('#loginform', ['log' =>'admin','pwd' => 'admin'], '#wp-submit');  
@JDGrimes
Copy link

JDGrimes commented Jan 6, 2018

I've experienced the same thing. The solution I came up with was to fill the field twice. I'm not sure that is really any different than adding a wait period or not. Trying what was suggested in #65 didn't seem to help. I wonder if filling the field twice helps to prime it for the second filling, rather than just adding more time. I don't remember if I tried just adding a wait period or not. Whatever works, I guess. I am using PhantomJS rather than Chrome, so it is also possible that they have different quirks.

@rahularyan
Copy link
Author

rahularyan commented Jan 6, 2018

@JDGrimes I tried it with all major browser drivers and faced same issue. Adding a wait surely solved it but that is making test slow. Though I tried using $I->waitForJs("document.readyState === 'complete'", 30); but this does nothing.
@lucatume why loginAsAdmin is not waiting for body to load? I have added many cepts for form but I don't face similar issue anywhere except login page.

@lucatume lucatume self-assigned this Jan 8, 2018
@lucatume lucatume added the bug label Jan 8, 2018
@lucatume
Copy link
Owner

lucatume commented Jan 8, 2018

Thanks for reporting the issue,

I've opened a branch (fix-login-as-issue-121) to try and fix the issue; it will wait for the login form to appear when in *WebDriver modules using the waitForElementVisible method.
If you are willing to try it out and let me know if it helps use composer update lucatume/wp-browser:dev-fix-login-as-issue-121 to pull it.

@rahularyan
Copy link
Author

rahularyan commented Jan 9, 2018 via email

@lucatume
Copy link
Owner

To move the discussion further: I'm using that code here with PhantomJS on Travis with no issues.
How many times, and driving which browser, are you using it?

@lucatume
Copy link
Owner

lucatume commented Apr 4, 2018

No activity for a long time on this one, @rahularyan could you please provide the information requested in #121 (comment)?

@rahularyan
Copy link
Author

As I said before, calling loginAsAdmin will work as expected. Issue comes only when I have to call loginAsAdmin multiple time. But right now I am using wait bypass this issue.

@lucatume
Copy link
Owner

lucatume commented Apr 4, 2018

The question is "How many times, and driving which browser, are you using it?"; if you want help please provide more information.

@rahularyan
Copy link
Author

4-5 times. Using chrome ;)

@lucatume
Copy link
Owner

lucatume commented Apr 5, 2018

Headless chrome? Could you please post the suite configuration file?

@lucatume lucatume closed this as completed May 7, 2018
@hive-4-apps
Copy link

hive-4-apps commented Jul 7, 2018

To avoid to report the same problem, I´m writing here.
Today, I´m using Selenium with chromedriver.exe and geckodriver.exe and I get the same issue.
I do not know if there was some changes but the bug seems to stay.

I tried loginAsAdmin and....

   $I->amOnPage('/wp-login.php');
   $I->wait(10);
   $I->submitForm('#loginform', ['log' =>'admin','pwd' => 'admin'], '#wp-submit'); 

I got this error

[PHPUnit\Framework\Exception] Undefined index: ELEMENT

lucatume added a commit that referenced this issue Nov 7, 2018
Introduce login re-attempts in WpWebDriver to avoid missing cookies issues, resolves #121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants