Protractor: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL

Created on 19 Feb 2016  ·  26Comments  ·  Source: angular/protractor

i use the example from "http://www.protractortest.org/#/tutorial"

// spec.js
describe('Protractor Demo App', function() {
  it('should have a title', function() {
    browser.get('http://juliemr.github.io/protractor-demo/');

    expect(browser.getTitle()).toEqual('Super Calculator');
  });
});

// conf.js
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

Now run the test with

protractor conf.js

Then the console display:
image

needs more info

Most helpful comment

@sallojusuresh, the below solution worked.
jasmineNodeOpts: {
defaultTimeoutInterval: 2500000
},
Question - When we can set a default time as above, where comes the use of setTimeout function in 'beforeEach' and done callbacks in 'it'. Any idea?

All 26 comments

You can find solution in below post: just go through whole post.

https://github.com/angular/protractor/issues/2941#issuecomment-186104304

Are you able to successfully start selenium? What happens if you use directConnect?

Closing stale issues.

im having same problem and the other post dont work for me.
@juliemr any solution for this? i tried allScriptsTimeout: 900000 but this dont solve the problem.

Doesn't work for me either. increase defaultTimeoutInterval doesn't solve it

@juliemr I'm having the same problem and increasing ScriptsTimeout does not work for me. Do you have any solution for this? Thank you.

Hi All,

I am running a test case in protractor getting timed out error. Here is the details. Please advice. Thank you

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

sample_spec.js

describe('Mcac App testing', function() {
browser.get('http://localhost:3000/integrated/myWeb.html');
beforeEach(function (done) {
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
setTimeout(function () {
console.log('inside timeout');
done();
}, 50000);
});
//browser.get(' http://localhost:3000/integrated/myWeb.html');
// browser.get('http://localhost:3000/integrated/myWeb.html').then(function() {
it('Email Address Validation', function()
{

        element(by.model('ctrl.formData.emailAddress')).sendKeys('').clear();
        element(by.model('ctrl.formData.emailAddress')).sendKeys('[email protected]');
        element(by.model('ctrl.formData.emailAddress')).getAttribute('value').then(function (value) {
            expect(value).toEqual('[email protected]');
        });


}, 10000);

// element(by.xpath("//button[text()='Confirm']")).click();
browser.sleep(5000);

});

config.js

// An example configuration file.
exports.config = {
directConnect: true,

// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},

// Framework to use. Jasmine is recommended.
framework: 'jasmine',

// Spec patterns are relative to the current working directory when
// protractor is called.
// specs: ['example_spec.js'],
//specs: ['mcac_spec.js'],
//specs: ['mcac_spec_mobile.js'],
specs: ['mcac_online.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 5000
}

};

any help much appreciated.

I had this issue and it was because of a repeating $timeout ($timeout blocks Protractor, while $interval doesn't).

To find the repeating $timeout, you can use Protractor's element explorer, for example:

$ protractor config/protractor.js --elementExplorer
Starting debugger agent.
Debugger listening on port 5858
> var body = element(by.css('body'))
> body.isPresent()
ScriptTimeoutError: Timed out waiting for asynchronous Angular tasks to finish after 15 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: By(css selector, body). 
The following tasks were pending:
 - $timeout: function () {
        // ......
    }

Thank you.

I found the issue. its because of url loading takes time and looking for
ng-app tag in html page.

best regards,
Narendra

Narendra...!

On 15 December 2016 at 06:12, Amy Boyd notifications@github.com wrote:

I had this issue and it was because of a repeating $timeout ($timeout
blocks Protractor, while $interval doesn't).

To find the repeating $timeout, you can use Protractor's element explorer,
for example:

$ protractor config/protractor.js --elementExplorer
Starting debugger agent.
Debugger listening on port 5858

var body = element(by.css('body'))
body.isPresent()
ScriptTimeoutError: Timed out waiting for asynchronous Angular tasks to finish after 15 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: By(css selector, body).
The following tasks were pending:

  • $timeout: function () {
    // ......
    }


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/protractor/issues/2963#issuecomment-267302567,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AViSFkiN29oWnH6AJ0P_wNY_LNzE2fglks5rISCYgaJpZM4Hd20v
.

Hi All,

I am running a test case in protractor getting timed out error. Here is the details. Please advice. Thank you

Failed: Timed out waiting for asynchronous Angular tasks to finish after 30 seconds. This may be because the current page is not an Angular application.

@sallojusuresh, the below solution worked.
jasmineNodeOpts: {
defaultTimeoutInterval: 2500000
},
Question - When we can set a default time as above, where comes the use of setTimeout function in 'beforeEach' and done callbacks in 'it'. Any idea?

I have fixed by the following way

 var originalTimeout;

    beforeEach(function() {
        originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
    });

    afterEach(function() {
      jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
    });

Thank you.

Narendra...!

On 11 March 2018 at 23:53, Md. Zahirul Haque notifications@github.com
wrote:

I have fixed by the following way

` var originalTimeout;

beforeEach(function() {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});

afterEach(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});`


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/protractor/issues/2963#issuecomment-372187210,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AViSFg7ITAW3XW5zky_-QXXmAudt11qDks5tdfE1gaJpZM4Hd20v
.

@NickTomlin You just made my day :) I have used directconnect & worked. It would be great if you shade some light on what directconnect actaully does

In my case, this error was caused by improper use of "fixture.detectChanges()" It seems this method is a event listener (async) which will only respond a callback when changes are detected. If no changes are detected it will not invoke the callback, resulting in a timeout error. Hope this helps :)

@juliemr Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. this error coming in my test again n again i used before each, after each, browser.sleep, increased the jasmine timeout iterval upto 100000. but my code is not run so please suggest me what could I do.

I got this issue and cannot resolve while increased the jasmine timeout up to 300000. So pls suggest me what should I do for it.

Could you provide simple example?

Solution to this is, if you are trying to write tests for non-angular app, goto runner.js at node_modules/protractor/built
Edit line # 210 to waitForAngularEnabled: false //true

@juliemr a suggestion to make this setting configurable.

you could do it in onPrepare() section:

onPrepare: async () => {
    await browser.waitForAngularEnabled(false);
    ....
}

I got the same problem, but the solutions provided here did not work for me. If you have time, please have a look to my question on Stack Overflow. The problem can easily be reproduced and I have a repo. I guess it is possible a bug.
https://stackoverflow.com/questions/53786401/error-debugging-protractor-with-node-8-async-await-and-angular-6

Expected false to equal true Because: Error logs present in console:Entry {
level: Level { name_: 'SEVERE', value_: 1000 },
message:
"ERROR" Error: formGroup expects a FormGroup instance. Please pass one in.\n\n Example:\n\n \n

\n \n
\n\n In your class:\n\n this.myGroup = new FormGroup({\n firstName: new FormControl()\n });\n at Function.e.missingFormException

getting issue while click on pop up button , any solution?

I has a similar problem with post and I have solved my problem adding HttpClientModule on imports:

beforeEach(() => {

TestBed.configureTestingModule({

    declarations: [],

    providers: [ CookieService, HttpClient],  

    imports: [HttpClientModule],
});

});

I has a similar problem with post and I have solved my problem adding HttpClientModule on imports:

beforeEach(() => {

TestBed.configureTestingModule({

    declarations: [],

    providers: [ CookieService, HttpClient],  

    imports: [HttpClientModule],
});

});

I personally had problems importing the HttpClientModule inside a testbed. It tries running your APIs in your unit tests and as a result, they fail. The right approach would be to use HttpClientTestingModule

@sallojusuresh, the below solution worked.
jasmineNodeOpts: {
defaultTimeoutInterval: 2500000
},
Question - When we can set a default time as above, where comes the use of setTimeout function in 'beforeEach' and done callbacks in 'it'. Any idea?

This is best solution just paste this piece of code in ur confing file it should resolve ur problem.

Was this page helpful?
0 / 5 - 0 ratings