I am trying to understand the documentation for Selenium's executeAsyncScript here (https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html) , for instance in their first example they have :
long start = System.currentTimeMillis();
((JavascriptExecutor) driver).executeAsyncScript(
"window.setTimeout(arguments[arguments.length - 1], 500);");
System.out.println(
"Elapsed time: " + System.currentTimeMillis() - start);
Now as far as I understand, the first argument is supposed to be a script, while the last one is a callback function, but in this example there is no callback, so what is going on here (arguments[] is empty right?).
If I wanted to have a function that returns a promise, and then print the promise, say doSomething().then(function(result) { return result;)}); how would this work with the executeAsyncScript function?
Thanks