Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timed out waiting for Protractor to synchronize with the page after 11 seconds

I am new to Protractor (can say just 1 day old) and have been trying to run end to end test.

However, every time I run conf.js, I am being displayed with "Timed out waiting for Protractor to synchronize with the page after 11 seconds."

Before posting this question, have tried all options given by other respondents, but still am unable to resolve the issue and thus request your help.

To support, below are the details of my configurations and spec js files:

Conf.js:

    exports.config = {
      directConnect: true,
      capabilities: {'browserName': 'chrome'},
      framework: 'jasmine',
      specs: ['example_spec.js'],
    jasmineNodeOpts: {
    defaultTimeoutInterval: 100000
      }
     };

example_spec.js:

    describe('forfirm homepage', function() {
        it('login window should open', function() {
         browser.get('https://www.forfirm.com');
         element(by.model('forfirm.email')).sendKeys('[email protected]');
         element(by.model('form.password')).sendKeys('Password');
             });
         });

Output received:

      Failures:
       1) forfirm homepage login window should open
       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. The following tasks were pending:
       - $timeout: function (){a.next(),h=f(j,5e3)}
       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. The following tasks were pending:
        - $timeout: function (){a.next(),h=f(j,5e3)}
    at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
    at Promise.invokeCallback_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
    at TaskQueue.execute_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
    at TaskQueue.executeNext_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)

   1 spec, 1 failure
   Finished in 22.022 seconds
   [launcher] 0 instance(s) of WebDriver still running
   [launcher] chrome #01 failed 1 test(s)
    [launcher] overall: 1 failed spec(s)
    [launcher] Process exited with error code 1

Also, while running the protractor conf.js, I could not see protractor launching Chrome browser.

like image 600
Sonal Dalal Avatar asked Apr 09 '16 05:04

Sonal Dalal


2 Answers

You should take a look on Timeouts and try to set all of them first

allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
    defaultTimeoutInterval: 120000
},

Update: i hate ignoreSynchronization, you should read about it, how to avoid it in official protractor documentation - try this:

conf.js

exports.config = {
directConnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example_spec.js'],
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
    defaultTimeoutInterval: 120000
},
onPrepare: function () {
    browser.driver.manage().window().maximize();
}};

example_spec.js

describe('forfirm homepage', function() {
it('login window should open', function() {
    browser.ignoreSynchronization = true;
    browser.get('https://www.forfirm.com');
    element(by.model('form.email')).sendKeys('[email protected]');
    element(by.model('form.password')).sendKeys('Password');
    browser.sleep(5000);
});});
like image 134
Michal Sviha Avatar answered Sep 22 '22 12:09

Michal Sviha


I believe this should solve the issue, as per Protractor official documentation at "https://github.com/angular/protractor/blob/master/docs/timeouts.md".

Interestingly, in our application, I see that this still takes 11 seconds default even though I have set the allScriptsTimeout to a value say 120 seconds.

I tried doing this in OnPrepare too, despite that I am seeing the same time out error stating Protractor synching with the page for 11 seconds. Any thoughts would be highly appreciated.

Below is an example of my config (Node - 4.2.4, Protractor - 3.1.1)

exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['DemoTest.js'],
  getPageTimeout: 120000,
  allScriptsTimeout: 120000,

  capabilities: {
    browserName: 'chrome',
    },

  onPrepare: function(){
      browser.ignoreSynchronization = true;
      getPageTimeout: 120000;
      allScriptsTimeout: 120000;
      jasmine.DEFAULT_TIMEOUT_INTERVAL = 180000;

   },
}
like image 37
Prakash Avatar answered Sep 18 '22 12:09

Prakash