我正在运行一个Angular应用程序,我试图在量角器上测试时获取当前的URL.哪一个使用?
browser.driver.getCurrentUrl()或browser.getCurrentUrl()?
解决方法
如果这是一个正在测试的Angular应用程序 – 请使用浏览器,否则使用 – browser.driver.
从relevant github issue引用@jmr:
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()并且不记得任何问题.