Protractor: open window and test url
Asked Answered
N

1

7

I'm trying to test a link in a table that opens a new window. I want to test the url of the new window.

What I have so far is this:

    it('Should verify new window url', function () {
    page.list.get(0).click().then(function () {
        browser.getAllWindowHandles().then(function (handles) {
            newWindowHandle = handles[1];
            browser.switchTo().window(newWindowHandle).then(function () {
                expect(browser.getCurrentUrl()).toMatch(/\/url/);
            });
        });
    });
});

Error: Error while waiting for Protractor to sync with the page: {}

Works if I remove the expect....I am confused about promises, can someone guide me in right direction please?

Nadiya answered 15/4, 2014 at 19:42 Comment(0)
N
10

Turns out that the new page does not have angular on it, therefore I had to use the underlying driver.

expect(browser.driver.getCurrentUrl()).toMatch(/\/url/);
Nadiya answered 16/4, 2014 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.