How to use browser.getCurrentUrl() in a protractor test?

前端 未结 2 1430
温柔的废话
温柔的废话 2020-12-18 06:22

I have been struggling with these lines of Protractor code today:

element(by.linkText(\"People\")).click();
browser.waitForAngular();        
var url = brows         


        
2条回答
  •  遥遥无期
    2020-12-18 06:39

    Instead of waitForAngular() call, wait for the URL to change:

    browser.wait(function() {
      return browser.getCurrentUrl().then(function(url) {
        return /index/.test(url);
      });
    }, 10000, "URL hasn't changed"); 
    

    Originally suggested by @juliemr at UnknownError: javascript error: document unloaded while waiting for result.

提交回复
热议问题