我有一组并行测试,当我在本地运行它们时从未遇到过这个问题.这只发生在我的小二节点网格上.当我尝试调用WebDriver.getCurrentUrl()时,我的测试一直很糟糕.错误消息是这样的:
org.openqa.selenium.WebDriverException: Session [035e8f79-fdd7-4492-a565-f803df792d3c] was terminated due to TIMEOUT
Command duration or timeout: 90 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'bos-mpky6', ip: '172.30.31.59', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=46.0.1, platform=LINUX, nativeEvents=false, acceptSslCerts=true, webdriver.remote.sessionid=035e8f79-fdd7-4492-a565-f803df792d3c, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 035e8f79-fdd7-4492-a565-f803df792d3c
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
at org.openqa.selenium.remote.RemoteWebDriver.getCurrentUrl(RemoteWebDriver.java:326)
起初,我认为这是一个配置问题,但我已将我的设置配置为超时超过几毫秒.以下是我用于集线器的配置:
{
"host": null,
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"browserTimeout": 0,
"jettyMaxThreads":-1
}
这是我用于两个节点的配置:
{
"capabilities":
[
{
"browserName": "firefox",
"version": "46.0.1",
"platform": "LINUX",
"maxInstances": 5
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"nodeTimeout":500000,
"port":5555,
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":500000
}
}
我没有使用Docker或类似的东西.我尝试过版本2.53.1,2.53.0,2.52.0和2.51.0的网格服务器,这个问题继续困扰着我的测试.有什么办法可以摆脱这个问题吗?我找不到与超时相关的配置设置,似乎摆脱了这一点.
最佳答案 当我调整超时和browserTimeout属性时,我遇到了同样的错误.我的解决方案是将集线器配置恢复为默认值.但你已经和我现在一样.
但我看到你的节点配置略有不同.
我使用Windows 7作为节点,这是我的配置:
{
"capabilities": [
{
"browserName": "firefox",
"maxInstances": 2,
"takesScreenshot": true,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "internet explorer",
"maxInstances": 1,
"version": "11",
"webdriver.ie.driver": "<MOUNT>\Selenium\IEDriverServer_2.53.1_32bit",
"takesScreenshot": true,
"platform": "WINDOWS",
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"_comment" : "Configuration for Node",
"cleanUpCycle":5000,
"timeout": 500,
"port": 8088,
"hubHost": V0001172,
"register": true,
"hubPort": 8089,
"maxSession": 1
}
}
我将seleniumProtocol添加到我的节点配置中.我不记得我在哪里发现了这个,但在我的设置中它起作用了.