硒 3.4.0
即 11
视窗 10
我正在使用 Webdriver(RemoteWebDriver) 启动 IE。但它卡在http://localhost//some_random_number并且没有进一步移动。启动 IE 的代码是:
WebDriver driver = null; String errMsg = "";
try {
DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setBrowserName("internet explorer");
URL sURL = null;
sURL = new URL("http://localhost:5558/wd/hub");
driver = new RemoteWebDriver(sURL, cap);
} catch (Exception e) {
throw e;
}
启动 HUB 和 IE 网格的命令是:
cd "<path to seleniumjar>" && D: && javaw -jar selenium-server-standalone-3.4.0.jar -port 4444 -role hub
cd "<path to seleniumjar and ie driver" && D: && javaw -Dwebdriver.ie.driver=IEDriverServer_64.exe -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub http://localhost:4444/grid/register -browser browserName="internet explorer",platform=WINDOWS,maxInstances=5 -port 5558
此外,整个 selenium 线程在这里挂起 3 小时,之后发生以下异常
Error: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'INNOSZPC00536', ip: '192.168.99.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
at com.automatics.packages.library.Web$Helper.launchIE(Web.java:2645)
at com.automatics.packages.library.Web$Helper.access$0(Web.java:2568)
at com.automatics.packages.library.Web.wbLaunchBrowser(Web.java:92)
at com.automatics.packages.testScripts.google_tc.test(google_tc.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.conn.LoggingInputStream.read(LoggingInputStream.java:87)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at ...
如果浏览器无法访问,我想在 30 秒内退出,如何将此默认的 3 小时超时重置为 30 秒。如果执行卡在本地主机页面上,该怎么办。