I want to use an async function call to run few scripts asynchronously but I am not able to achieve it using javaScriprtExecutor‘s executeAsyncScript() function. Here is a small snippet for your reference.
I believe the function ‘executeAsyncScript’ should run asynchronously and the function call at line #2 (being faster in nature) should get finished before the executeAsyncScript(). but this not happening. Function calls at line no 2 is getting called only when execution on of function 1 ends including 5-second delay!!
Can anyone help me in understanding what is it I am not able to see here?
1. js.executeAsyncScript("window.setTimeout(arguments[arguments.length - 1], 5000);");
2. driver.findElement(By.xpath("//input")).sendKeys("Search term!!");
With this sequence, the browser wais for 5 seconds and then do sendkeys().