硒网连接超时

时间:2017-05-26 09:25:20

标签: java selenium-grid

我想使用Bamboo CI服务器自动化测试。

我使用this jar

在服务器和节点上设置了selenium-grid

我能够在网格控制台中看到节点,但是当我运行测试时,我有一个错误信息:

setUp(com.lazerycode.selenium.tests.TestGoogle)  Time elapsed: 128.927 sec  <<< FAILURE!
org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Connect to XXX.XXX.XXX:5555 [/XXX.XXX.XXX/2] failed: Connection timed out (Connection timed out)
Command duration or timeout: 127.38 seconds
   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:215)
   at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
   at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
   at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
   at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22(ProtocolHandshake.java:365)
   at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
   at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
   at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
   at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
   at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
   at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
   at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
   at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
   at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
   at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:368)
   at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
   at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
   at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
   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.lazerycode.selenium.config.DriverFactory.instantiateWebDriver(DriverFactory.java:97)
   at com.lazerycode.selenium.config.DriverFactory.getDriver(DriverFactory.java:46)
   at com.lazerycode.selenium.DriverBase.getDriver(DriverBase.java:35)
   at com.lazerycode.selenium.tests.TestGoogle.setUp(TestGoogle.java:19)
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Connect to XXX.XXX.XXX:5555 [/XXX.XXX.XXX] failed: Connection timed out (Connection timed out)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'vps409XXX', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-78-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
   at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:112)
   at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
   at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
   at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
   at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:543)
   at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
   at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1584)
   at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
   at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1228)
   at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
   at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:481)
   at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1553)
   at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
   at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1130)
   at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
   at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
   at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
   at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:320)
   at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
   at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
   at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:112)
   at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
   at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
   at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
   at java.lang.Thread.run(Thread.java:748)

我试图运行的代码:

final URL seleniumGridURL = new URL(System.getProperty("gridURL"));
final String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
final String desiredPlatform = System.getProperty("desiredPlatform");

if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
    desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
}

if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
    desiredCapabilities.setVersion(desiredBrowserVersion);
}

webdriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);

1 个答案:

答案 0 :(得分:0)

我想我找到了答案:竹子服务器在我的本地网络之外,因此它无法访问我的机器。