Trying to wrap my head around Selenium's executeAsyncScript
documentation found here (https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html). In their initial example, they present:
long start = System.currentTimeMillis();
((JavascriptExecutor) driver).executeAsyncScript(
"window.setTimeout(arguments[arguments.length - 1], 500);");
System.out.println(
"Elapsed time: " + System.currentTimeMillis() - start);
It seems like the first argument should be a script and the last one a callback function. However, in this example, there is no callback present. So, what exactly is happening here (especially since arguments[] is empty)?
If I wanted to create a function that returns a promise and then print that promise using something like
doSomething().then(function(result) { return result;)});
, how would I go about doing this with the executeAsyncScript
method?
Any insights or guidance would be greatly appreciated.