Protractor: timed out after 10000 msec waiting for spec to complete

artem_golovin picture artem_golovin · Mar 31, 2014 · Viewed 8.8k times · Source

I have several protractor tests and sometimes I get a error saying:

Message:
     timeout: timed out after 10000 msec waiting for spec to complete
   Stacktrace:
     undefined

It can be randomly happening on some tests. I usually test on BrowserStack and it shows the error once in 3-5 builds. But recently I tried SauceLabs and almost every (every!) but not all the tests fail with that error. Probably, SauceLabs are just significantly slower so I get the error more often...

So here are the questions:

  1. Is there a way in Protractor/Selenium to change test running timeout? It needs to be changed on BrowserStack/Saucelabs as well.
  2. Why am I getting the error so often? Is there anything wrong with my tests? Most of the doesn't seem complicated or long running. Again, on local machine it's almost always fine.

Here is the example:

   it('should check that login gives error on empty or incorrect email', function () {
      p.get('/#/login');
      p.findElement(protractor.By.css('button[type="submit"]')).click();
      expect(p.findElement(protractor.By.css('.alert-danger')).getText()).toEqual('E-mailadres is niet geldig');
      p.findElement(protractor.By.model('user.email')).sendKeys('test-1xtc.vc');
      p.findElement(protractor.By.css('button[type="submit"]')).click();
      expect(p.findElement(protractor.By.css('.alert-danger')).getText()).toEqual('E-mailadres is niet geldig');
      p.findElement(protractor.By.model('user.email')).clear();
    });

The app is using AngularJS, selenium 2.20, protractor 0.20.1

Answer

glepretre picture glepretre · Mar 31, 2014

Is there a way in Protractor/Selenium to change test running timeout?

Yes :) You can do it via the allScriptsTimeout in your Protractor config (from Protractor FAQ)

You can also set the defaultTimeoutInterval in jasmineNodeOpts option (from Protractor referenceConf.js)

Why am I getting the error so often? Is there anything wrong with my tests? Most of the doesn't seem complicated or long running. Again, on local machine it's almost always fine.

Hard to say without seeing your tests. The example you provided looks good to me.