I am trying to implement the following test case:
- click on the logo on the page
- claim that a new browser window has opened (tab in Chrome) and check the current URL
The problem is that the page opened in a new browser window is not an angular page, but the main page I click on is the angular page.
Here is my first attempt:
it("should show logo", function () { var logo = scope.page.logo; expect(logo.isDisplayed()).toEqual(true); // opens a new page on click logo.click().then(function () { browser.getAllWindowHandles().then(function (handles) { browser.switchTo().window(handles[1]).then(function () { expect(browser.getCurrentUrl()).toEqual('http://myurl.com/'); }); // switch back to the main window browser.switchTo().window(handles[0]); }); }); });
which fails:
Error: Error while trying to synchronize the tracer with the page: "angular could not be found in the window"
which is understandable.
My second attempt was to play with the ignoreSynchronization boolean flag:
browser.ignoreSynchronization = true; logo.click().then(function () { browser.getAllWindowHandles().then(function (handles) { browser.switchTo().window(handles[1]).then(function () { expect(browser.getCurrentUrl()).toEqual('http://myurl.com/'); });
This actually makes this particular test pass without any errors, but it affects every test that runs after that because the browser is a global object and is shared between the tests. The transcavator is no longer synchronized with angular on the page, which results in all kinds of errors.
How do I perform a test?
As a workaround, I can change the restartBrowserBetweenTests parameter to true and change the ignoreSynchronization value without any problems - but this slows down the tests significantly.
javascript angularjs testing protractor end-to-end
alecxe Feb 14 '15 at 0:29 2015-02-14 00:29
source share