protractor icon indicating copy to clipboard operation
protractor copied to clipboard

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

Open tianyirao opened this issue 10 years ago • 26 comments

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

tianyirao avatar Feb 19 '16 10:02 tianyirao

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

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

sallojusuresh avatar Feb 19 '16 10:02 sallojusuresh

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

NickTomlin avatar Feb 19 '16 15:02 NickTomlin

Closing stale issues.

juliemr avatar Apr 25 '16 22:04 juliemr

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.

dayanamcc avatar Oct 25 '16 00:10 dayanamcc

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

capsule5 avatar Oct 25 '16 16:10 capsule5

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

annienguyen16 avatar Nov 04 '16 18:11 annienguyen16

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.

reddynr avatar Dec 06 '16 16:12 reddynr

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 () {
        // ......
    }

amyboyd avatar Dec 15 '16 11:12 amyboyd

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 [email protected] 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 .

reddynr avatar Dec 15 '16 16:12 reddynr

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.

Shibashis2016 avatar Mar 15 '17 08:03 Shibashis2016

@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?

suswari avatar Apr 13 '17 17:04 suswari

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;
    });

zahiruldu avatar Mar 12 '18 03:03 zahiruldu

Thank you.

Narendra...!

On 11 March 2018 at 23:53, Md. Zahirul Haque [email protected] 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 .

reddynr avatar Mar 12 '18 12:03 reddynr

@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

stemkar123 avatar May 16 '18 19:05 stemkar123

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 :)

AFigueroa avatar Jun 14 '18 18:06 AFigueroa

@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.

satyendrabhan avatar Jul 25 '18 11:07 satyendrabhan

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.

binhvtle avatar Aug 29 '18 11:08 binhvtle

Could you provide simple example?

CrispusDH avatar Aug 29 '18 16:08 CrispusDH

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.

abhikhan25 avatar Sep 29 '18 09:09 abhikhan25

you could do it in onPrepare() section:

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

CrispusDH avatar Sep 29 '18 13:09 CrispusDH