量角器 browser.driver.getCurrentUrl 与 browser.getCurrentUrl

Protractor browser.driver.getCurrentUrl vs browser.getCurrentUrl

我是 运行 一个 Angular 应用程序,在量角器上测试时我正试图获取当前的 URL。使用哪一个?

browser.driver.getCurrentUrl()browser.getCurrentUrl() ?

如果这是一个 Angular 正在测试的应用程序 - 使用 browser,否则 - browser.driver.

引用@jmr 来自relevant github issue:

If you need to interact with a non-Angular page, you may access the wrapped webdriver instance directly with browser.driver.


不过,请注意,如果这是 Angular 正在测试的应用程序 ,两者都可以使用。甚至有人说,如果同步时间比平时长,发现 browser.driver 更可靠:

Just to add to this - I find that browser.driver works better on AngularJS apps that take time to sync. I have tried both and for some reason browser.driver is more reliable.

不过,我个人使用过browser.getCurrentUrl(),想不起来有什么问题。