Claygirl
Claygirl

Reputation: 349

Browser.wait times out on page synchronization

I have a case where I need to wait for the "Waiting for data to load" modal to disappear and said modal depends on $http request running.

I've used browser.wait statement, using Expected Conditions according to Protractor API.
My statement has currently this form:

beforeEach(function() {
    browser.wait(element(EC.invisibilityOf(element(by.css(".msg-overlay"))), 30000);
});

it("describes something", function() {
    ...do some actions involving clicking...
})

Unfortunately spec always fails with message:

Message:
  Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
  While waiting for element with locator - Locator: By(css selector, .msg-overlay).
  The following tasks were pending:
   - $http: 
Stack:
  Error: Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
  While waiting for element with locator - Locator: By(css selector, .msg-overlay).
  The following tasks were pending:
   - $http: 
      at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
      at Promise.invokeCallback_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
      at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
      at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)

I don't want to set allScriptsTimeout to 30000, as this would slow down actual fails, I would just like Protractor to wait for one modal to disappear. Help?

Upvotes: 1

Views: 575

Answers (1)

alecxe
alecxe

Reputation: 474281

I think you can temporarily change the allScriptsTimeout on the fly in as similar fashion as you would do with the jasmine default timeout interval (not tested):

var originalTimeout;

beforeEach(function() {
    originalTimeout = browser.allScriptsTimeout;
    browser.allScriptsTimeout = 35000;
    browser.wait(element(EC.invisibilityOf(element(by.css(".msg-overlay"))), 30000);
});

afterEach(function() {
    browser.allScriptsTimeout = originalTimeout;
});

Upvotes: 0

Related Questions