[英]after executing, window.setTimeout() throws 'Uncaught TypeError: undefined is not a function'?
[英]Why does 'executeAsyncScript (window.setTimeout (5000))' function in Java for selenium is holding the next function to execute after 5 seconds?
我想使用异步函数调用来异步运行一些脚本,但是我无法使用javaScriprtExecutor的executeAsyncScript()函数来实现它。 这是一个小片段供您参考。
我相信函数“ executeAsyncScript”应该异步运行,并且在executeAsyncScript()之前,第2行(本质上会更快)上的函数调用应该完成。 但这没有发生。 仅当功能1的执行结束(包括5秒的延迟)时,才会调用第2行的函数调用!
有人可以帮助我了解我在这里看不到的内容吗?
1. js.executeAsyncScript("window.setTimeout(arguments[arguments.length - 1], 5000);");
2. driver.findElement(By.xpath("//input")).sendKeys("Search term!!");
按照此顺序,浏览器将退出5秒钟,然后执行sendkeys()。
两个函数executeAsyncScript和execteScript都会阻止WebDriver控制流,直到它们完成。 这就是为什么延迟5秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.