Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8334639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:25:16+00:00 2026-06-09T03:25:16+00:00

Why am I getting an exception with selenium 2.25.0 when trying to execute asynchronous

  • 0

Why am I getting an exception with selenium 2.25.0 when trying to execute asynchronous script.

//navigate to my test page.

String script = "var callback = arguments[arguments.length - 1];"  +
                "getResult(callback)";

Object result = ((JavascriptExecutor)driver).executeAsyncScript(script, "");

System.out.println(result);

The test page contains the following script:

var result = true;
function getResult(callback){
    window.setTimeout(function(){callback(true);}, 3000);
}

This throws an exception:

FAILED: testSeleniumAsync
org.openqa.selenium.TimeoutException: Script execution failed. Script: var callback = arguments[arguments.length - 1];getResult(callback);
 Timed out waiting for asyncrhonous script result after 2 ms (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-27-generic', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
Session ID: 6347b507cf22b6c2d3312937a82a0a02
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

If I remove the setTimeout from my script and I call callback it works. But this is not what I want.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:25:17+00:00Added an answer on June 9, 2026 at 3:25 am

    Its very strange that the API is timing out in 2 ms.

    I am guessing that the script time out is somehow incorrectly configured (<= 0sec). Since your window timeout occurs after 3 secs, try setting the script time out to some value greater than 3 secs, before you make the call.

    Like so:

    driver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS);
    

    That might work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to authenticate to https url , but iam getting exception . Below
I am getting an exception error, Input string was not in a correct format.
I am getting this exception when trying to run my PHP unit tests: Fatal
I am getting this exception: Collection was modified; enumeration operation may not execute. Directly
I am trying to use Selenium RC but i keep getting this error whenever
i was running a test remotely on internet explorer, and when using navigate().to() selenium
I'm getting exception when i'm running my jsp page, in which i've embedded the
I have been trying to execute a selenium.attachFile command to upload a file- sel.attachFile(dom_locator,/home/xyz/Desktop/tstfl.txt);
I'm raising a Selnium-server (the jar), and getting this exception without trying to talk
Hi following is my code...I am trying to synchronize 2 database.. but getting exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.