Protractor e2e Tests Login Redirection

喜欢而已 提交于 2019-12-02 23:01:48

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.

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!