如果时间超过20秒,pageLoadTimeout将不起作用

时间:2019-06-07 06:59:00

标签: java selenium selenium-firefoxdriver

我想知道何时未在40秒钟内加载url,但是大约20秒钟后,它将引发WebDriverException而不是预期的TimeoutException。我用来获取超时异常的网址是http://www.google.com:81/

我尝试将硒更新为3.5.1

WebDriver fd = new FirefoxDriver();
        fd.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
        try {
            fd.get(url);
            System.out.println("OK: " + url);
        } catch (TimeoutException e) {
            System.out.println("ERROR-Timeout: " + url);
        } catch (WebDriverException e) {
            System.out.println("ERROR-Not Found: " + url);
        }

我希望它在未加载40秒后引发TimeoutException,但在未加载20秒后会引发WebDriverException。

这是堆栈跟踪:

org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=netTimeout&u=http%3A//www.google.com%3A81/&c=UTF-8&f=regular&d=The%20server%20at%20www.google.com%20is%20taking%20too%20long%20to%20respond.
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
System info: host: 'NIKHIL-JINDIA', ip: '172.16.20.63', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\techn\AppData\Local\Temp\rust_mozprofile.Z4fQHiD8zfkn, rotatable=false, moz:geckodriverVersion=0.24.0, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, moz:headless=false, platform=ANY, moz:accessibilityChecks=false, moz:useNonSpecCompliantPointerOrigin=false, acceptInsecureCerts=false, browserVersion=67.0.1, moz:shutdownTimeout=60000.0, platformVersion=10.0, moz:processID=18516.0, browserName=firefox, moz:buildID=20190529130856, javascriptEnabled=true, platformName=windows, setWindowRect=true, moz:webdriverClick=true}]
Session ID: f032f78b-ae01-487f-9efb-841685121032
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:368)
    at validator.Validator.checkURL(Validator.java:109)
    at validator.Validator.lambda$0(Validator.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案