Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor browser.driver.getCurrentUrl vs browser.getCurrentUrl

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() ?

like image 317
Joao Falcao Avatar asked Mar 23 '26 04:03

Joao Falcao


1 Answers

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.

like image 90
alecxe Avatar answered Mar 26 '26 10:03

alecxe