org.openqa.selenium.ScriptTimeoutException:脚本超时引发以下代码工作
driver.manage().timeouts().setScriptTimeout(60, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
if (System.getProperty("os.name").contains("Mac")){
System.setProperty("webdriver.chrome.driver", ResourceHelper.getResourcePath("/src/main/resources/drivers/chromedriver"));
driver = ThreadGuard.protect(new ChromeDriver(options));
JavascriptExecutor jsDriver = (JavascriptExecutor) driver;
ngDriver = new NgWebDriver(jsDriver);
ngDriver.waitForAngularRequestsToFinish();
}
else if(System.getProperty("os.name").contains("Window")){
System.setProperty("webdriver.chrome.driver", ResourceHelper.getResourcePath("/src/main/resources/drivers/chromedriver.exe"));
driver = ThreadGuard.protect(new ChromeDriver(options));
driver.manage().timeouts().setScriptTimeout(60, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
JavascriptExecutor jsDriver = (JavascriptExecutor) driver;
ngDriver = new NgWebDriver(jsDriver);
ngDriver.waitForAngularRequestsToFinish();
}
return driver;
}
以上代码在执行时会引发错误-
org.openqa.selenium.ScriptTimeoutException: script timeout