Protractor browser.driver.getCurrentUrl vs browser.getCurrentUrl

情到浓时终转凉″ 提交于 2019-12-01 05:37:18

问题


I'm running an Angular app and I'm trying to get the current URL when testing on protractor. Which one to use?

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


回答1:


If this is an Angular application under test - use browser, otherwise - browser.driver.

To quote @jmr from a relevant github issue:

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


Though, note that both are gonna work if this is Angular application under test. Some people even said that found browser.driver more reliable if it the sync time is longer than usual:

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.

Though, I've personally used browser.getCurrentUrl() and cannot recall any problems.



来源:https://stackoverflow.com/questions/33439399/protractor-browser-driver-getcurrenturl-vs-browser-getcurrenturl

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