Protractor e2e Tests Login Redirection

前端 未结 2 1185
梦谈多话
梦谈多话 2021-02-04 05:02

Currently have a partial end-to-end test that enters a username/password and clicks \'sign in\'.

It does that successfully, but concludes at a \"thanks you\'re logged in

相关标签:
2条回答
  • 2021-02-04 05:29

    Have you tried using an explicit wait?

        return browser.driver.wait(function() {
            return browser.driver.getCurrentUrl().then(function(url) {
                return /success/.test(url);
            });
        }, 10000);
    

    Your code would be like that:

      // Click to sign in - waiting for Angular as it is manually bootstrapped.
      userLoginBtn.click();
      return browser.driver.wait(function() {
            return browser.driver.getCurrentUrl().then(function(url) {
                return /success/.test(url);
            });
      }, 10000);
    
    0 讨论(0)
  • 2021-02-04 05:43

    Your post lacks information but I'll try to make an assumption:

    I suspect that your "thanks you're logged in" page makes javascript redirect after a timeout.

    So after you click "Login", the browser loads "thanks you're logged in" page, and since the second parameter to .then() does nothing, browser.waitForAngular() fails because there is no angular on that page.

    You should try to use something like browser.driver.wait() with a reasonable timeout to detect url change (described here: https://github.com/angular/protractor/issues/610) and trigger browser.waitForAngular() after the browser get to /success page.

    0 讨论(0)
提交回复
热议问题