Protractor: ScriptTimeoutError: asynchronous script timeout: result was not received in 0 seconds

Created on 27 Sep 2013  Â·  10Comments  Â·  Source: angular/protractor

I'm getting this error occasionally, making all previously-passed tests failed. I saw this code driver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS); from

http://stackoverflow.com/questions/11646586/unable-to-execute-selenium-asynchronous-script

but I don't know how to run something like that from my protractor test. How should I proceed with this?

docs question

Most helpful comment

@juliemr - with latest versions of protractor, you may want to update the docs again by replacing ptor.driver with browser

onPrepare: function() {
    // Override the timeout for webdriver.
    browser.manage().timeouts().setScriptTimeout(60000);
  },

All 10 comments

You can either call the setScriptTimout statement from a beforeEach block in your test, or from the onPrepare block in the configuration file.

should I update this in the document? This happens a lot to me

Was it just setScriptTimeout() or ptor.setScriptTimeout() in beforeEach block? I tried both but the same thing happened. I put onPrepare: function(){ setScriptTimeout(5000); } into my exports.config, doesn't work as well...

is this the way to go? ptor.manage().timeouts().setScriptTimeout(10000);?

I had the same problem. My application takes a long time to load and I was getting timouts. Just add this code to your Protractor configuration file. Make sure you are using the latest version (0.10.0).

  onPrepare: function() {
    // Override the timeout for webdriver.
    ptor.driver.manage().timeouts().setScriptTimeout(60000);
  },

yup it works for me. Thank you all. Is this issue is so common, can we put
it down somewhere for latter reference?

On Monday, 30 September 2013, Andres Dominguez wrote:

I had the same problem. My application takes a long time to load and I was
getting timouts. Just add this code to your Protractor configuration file.
Make sure you are using the latest version (0.10.0).

onPrepare: function() {
// Override the timeout for webdriver.
ptor.driver.manage().timeouts().setScriptTimeout(60000);
},

—
Reply to this email directly or view it on GitHubhttps://github.com/angular/protractor/issues/117#issuecomment-25335765
.

Added more clarification to the docs with a729e35553f2f7d47d742babcc8fa2ab2860b26a

@juliemr - with latest versions of protractor, you may want to update the docs again by replacing ptor.driver with browser

onPrepare: function() {
    // Override the timeout for webdriver.
    browser.manage().timeouts().setScriptTimeout(60000);
  },

@juliemr , I've placed my browser.driver.manage().timeouts().setScriptTimeout in my beforeEach, but the timeout is not respected in the test. Here's example code that counts down 15 seconds, with a supposed 10 second timeout. The test counts down all of the way through 15 seconds without stopping/timing out. Can you advise?

var baseFuncs = require("../../pages/ams.base.po.js");\
describe('quick test - smoke 1', function () {
beforeEach(function () {
browser.driver.manage().timeouts().setScriptTimeout(10000);
baseFuncs.getBasePage("foo1");
});
it('foo - bar1', function () {
baseFuncs.countDown(15000);
});
afterEach(function () {
console.log("done with 1");
});
});

I am getting a similar error could you please help me out. I tried the above options but I still see the issue.

[18:00:34] E/plugins - ScriptTimeoutError: asynchronous script timeout: result was not received in 60 seconds
(Session info: chrome=66.0.3359.139)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object.checkLegacyResponse (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.executeScript()
at Driver.schedule (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at Driver.executeAsyncScript (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\webdriver.js:891:17)
at run (X:\projects\Protractor\COSTCO_APP\node_modules\protractor\builtbrowser.js:59:33)
at ProtractorBrowser.to.(anonymous function) [as executeAsyncScript] (X:\projects\Protractor\COSTCO_APP\node_modules\protractor\builtbrowser.js:67:16)
at Object.waitForPromise (X:\projects\Protractor\COSTCO_APP\node_modules\protractor-xhr-only-plugin\index.js:60:10)
at resolver (X:\projects\Protractor\COSTCO_APP\node_modules\protractor\built\plugins.js:194:51)
at new ManagedPromise (X:\projects\Protractor\COSTCO_APP\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at Plugins.safeCallPluginFun (X:\projects\Protractor\COSTCO_APP\node_modules\protractor\built\plugins.js:210:20)
at promises.pluginObjs.filter.map.pluginObj (X:\projects\Protractor\COSTCO_APP\node_modules\protractor\built\plugins.js:219:40)
at Array.map (native)

Was this page helpful?
0 / 5 - 0 ratings