OS: Arch Linux (os.version: '4.6.4-1-ARCH')
Selenium Version: 2.53.0
Browser: chromium, chrome, firefox
Browser Version:
const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
// Tried with firefox, google-chrome and chromium
let options = new chrome.Options();
options.setChromeBinaryPath('/usr/bin/google-chrome-stable');
let driver = new webdriver.Builder()
.forBrowser('firefox')
.usingServer('http://localhost:4444/wd/hub')
//.setChromeOptions(options)
.build();
driver.get('http://google.com');
driver.executeAsyncScript(() => {
var callback = arguments[arguments.length - 1];
window.setTimeout(() => {
callback({hamid: 'hamid'});
}, 500)
})
It's supposed to call the callback after setTimeout, but got an error.
17:20:05.585 INFO - Executing: [execute async script: return (() => {
var callback = arguments[arguments.length - 1];
window.setTimeout(() => {
callback({hamid: hamid});
}, 500)
}).apply(null, arguments);, []])
17:20:05.718 WARN - Exception thrown
org.openqa.selenium.TimeoutException: Timed out waiting for async script result after 1ms
Command duration or timeout: 129 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
you have to first set the execute script timeout, it defaults to 0
webdriver.manage().timeouts().setScriptTimeout(10000); // 10 seconds
I think the documentation may be off a bit, i don't believe it's accurate that 0 means 'indefinite' looks like 0 means, must return immediately :)
The documentation of executeAsyncScript doesn't mention it, even on the examples.
Thank you.
@jleyba might want to update some of those docs?