Zack Macomber
Zack Macomber

Reputation: 6905

Error while waiting for Protractor to sync with the page: {} when using browser.getCurrentUrl()

All of the code below prior to browser.getCurrentUrl() works fine. What do I need to tweak in this code to wait long enough to get the current url without getting "Error while waiting for Protractor to sync with the page: {}"?

it("should order a healthchek", function() {
    if (uiURL != null) {
        browser.get(uiURL);
        browser.driver.sleep(2000);
        element(by.id('outerSearch')).sendKeys('healthchek');
        browser.driver.sleep(2000);
        element(by.css('.serviceList')).element(by.repeater('t in state.tests').row(0)).element(by.css('.text')).click();
        browser.driver.sleep(2000);
        element(by.model('order.vet')).sendKeys('Dr. Smith');
        browser.driver.sleep(2000);
        element(by.css('.orderBottom')).element.all(by.css('.innerButton')).first().click().then(function() {
            browser.driver.wait(function() {
                browser.getCurrentUrl().then(function(url) {
                    console.log(url);
                });
            });
        });
    }
    expect(2).toEqual(2);
});

Upvotes: 1

Views: 1375

Answers (1)

Zack Macomber
Zack Macomber

Reputation: 6905

Looks like this does the trick:

browser.driver.wait(function() {
    return browser.driver.getCurrentUrl().then(function(url) {
        expect(url).toEqual('http://localhost/ui/done');
        console.log(url);
        return url;
    });
});

Upvotes: 2

Related Questions