Closed demisx closed 10 years ago
In https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests, this is addressed: If you need to interact with a non-Angular page, you may access the wrapped webdriver instance directly with browser.driver
I'll try to make this a bit more prominent when redoing the docs, if it's confusing.
Thank you Julie. I get it at a high-level, but what was a little confusing why I had to use browser.driver.getCurrentUrl().toMatch...
in the test below, whereas the same call without driver
browser.getCurrentUrl().toMatch
would fail with a protractor sync error.
it "opens Facebook popup when clicked on FB login button", ->
loginPage.get()
loginPage.clickFBLoginButton()
browser.getAllWindowHandles().then (handles) ->
browser.switchTo().window handles[1]
expect(browser.driver.getCurrentUrl()).toMatch /https:\/\/www.facebook.com\/login.php.*/
return
Perhaps, when if I start testing at window handles level, I need to work with the webdriver directly. Would be nice to have some docs pointing out scenarios on when to use one vs. other. Thank you.
Hi @demisx do you have the answer to your question on April 1, 2014? I am confused on this as well.
@ryancat Hi there. As far as I understood, browser.driver.x
is for interaction with non-Angular pages and browser.x
methods are wrappers for interacting with Angular pages.
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.
I think more clarity needs to added in relation to this as why not just use browser.driver
as it works on both Angular and non-Angular apps and therefore eliminates this confusion as to which one to use.
Can someone please explain in plain English (or point to docs) on when I should use
browser.driver
and whenbrowser
when calling methods? For example:Thanks.