获取" org.openqa.selenium.WebDriverException:转发新会话时出错转发请求时出错连接到"连接集线器与节点

时间:2018-05-31 10:00:42

标签: selenium jenkins selenium-webdriver selenium-grid

操作系统: Linux Selenium版本:** 3.12 **浏览器: Chrome V66, chromedriver 2.38

以下是我的网格配置: Hub(Linux)使用Selenium Grid Jenkins插件在Jenkins机器(https://jenkins.us.abc.edu)上运行。

现在我尝试用json注册我的Node,如下所示并启动Node: java -jar -Dwebdriver.chrome.driver = chromedriver selenium-rver-standalone-3.12.0.jar -role node -nodeConfig node.json

node.json

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "internet explorer",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  **"port": 17946,**
  "register": true,
  "registerCycle": 5000,
  **"hub": "http://jenkins.us.abc.edu:4444",**
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

以下是节点控制台:

[uanem@usv-selapp-01 ~]$ java -jar -Dwebdriver.chrome.driver=chromedriver selenium-rver-standalone-3.12.0.jar -role node -nodeConfig node.json
09:37:49.054 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3'
09:37:49.059 INFO [GridLauncherV3$3.launch] - Launching a Selenium Grid node on port 17946
2018-05-28 09:37:49.175:INFO::main: Logging initialized @490ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:37:49.324 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 17946
09:37:49.324 INFO [GridLauncherV3$3.launch] - Selenium Grid node is up and ready to register to the hub
09:37:49.332 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
09:37:49.332 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://jenkins.us.umuc.edu:4444/grid/register
09:37:50.866 INFO [SelfRegisteringRemote.registerToHub] - Updating the node configuration from the hub
09:37:50.965 WARN [SelfRegisteringRemote.registerToHub] - error getting the parameters from the hub. The node may end up with wrong timeouts.hudson.plugins.selenium.JenkinsCapabilityMatcher could not be coerced to instance
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'usv-selapp-01.us.umuc.edu', ip: '10.190.33.90', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.el7.x86_64', java.version: '1.8.0_144'
Driver info: driver.version: unknown
09:37:50.965 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
09:39:11.333 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://jenkins.us.umuc.edu:4444/grid/register
09:39:11.392 INFO [SelfRegisteringRemote.registerToHub] - Updating the node configuration from the hub
09:39:11.404 WARN [SelfRegisteringRemote.registerToHub] - error getting the parameters from the hub. The node may end up with wrong timeouts.hudson.plugins.selenium.JenkinsCapabilityMatcher could not be coerced to instance
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'usv-selapp-01.us.umuc.edu', ip: '10.190.33.90', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.el7.x86_64', java.version: '1.8.0_144'
Driver info: driver.version: unknown
09:39:11.405 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
09:40:31.602 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://jenkins.us.umuc.edu:4444/grid/register
09:40:31.632 INFO [SelfRegisteringRemote.registerToHub] - Updating the node configuration from the hub
09:40:31.642 WARN [SelfRegisteringRemote.registerToHub] - error getting the parameters from the hub. The node may end up with wrong timeouts.hudson.plugins.selenium.JenkinsCapabilityMatcher could not be coerced to instance
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'usv-selapp-01.us.umuc.edu', ip: '10.190.33.90', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.el7.x86_64', java.version: '1.8.0_144'
Driver info: driver.version: unknown
09:40:31.642 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
09:41:51.809 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://jenkins.us.umuc.edu:4444/grid/register
09:41:51.850 INFO [SelfRegisteringRemote.registerToHub] - Updating the node configuration from the hub
09:41:51.856 WARN [SelfRegisteringRemote.registerToHub] - error getting the parameters from the hub. The node may end up with wrong timeouts.hudson.plugins.selenium.JenkinsCapabilityMatcher could not be coerced to instance
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'usv-selapp-01.us.umuc.edu', ip: '10.190.33.90', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.el7.x86_64', java.version: '1.8.0_144'
Driver info: driver.version: unknown
09:41:51.856 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
Here i could see the node is connected hub in my Jenkins Selenium Grid page at "10.190.33.90"

以下是我的示例脚本:

@Test
    public void GoogleTest() throws Exception
    {

        System.out.println("I am in test");

        DesiredCapabilities capabilities = DesiredCapabilities.chrome();



        System.out.println("I am after setting chromedriver path ");

        **remoteWD = new RemoteWebDriver(new URL("http://usv-bmsapp-01.us.abc.edu:4444/wd/hub"), capabilities);**
        **//remoteWD = new RemoteWebDriver(new URL("https://jenkins.us.abc.edu:4444/wd/hub"), capabilities);** 
        //remoteWD = new ChromeDriver(); 

        System.out.println("I am after RMD");

        remoteWD.get("http://www.google.com"); 
        WebElement element = remoteWD.findElement(By.name("q"));
        element.sendKeys("Selenium WebDriver"); 
        element.submit();
        Thread.sleep(10000);
        System.out.println(remoteWD.getTitle());
        remoteWD.quit();

    }

由于安全原因或我无法连接的任何问题" https://jenkins.us.abc.edu:4444/wd/hub",但是当我给出这样的服务器名称" http://usv-bmsapp-01.us.abc.edu:4444/wd/hub&#34 ;我能够连接。

以下是我收到的错误消息。有人可以在我错的地方帮助我吗?

Running gridtest.GridTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@7dc5e7b4
I am before test
I am in test
I am after setting chromedriver path 
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 95.6 sec <<< FAILURE!
GoogleTest(gridtest.GridTest)  Time elapsed: 94.334 sec  <<< FAILURE!
org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Connect to 10.190.33.90:17946 [/10.190.33.90] failed: Connection timed out
Command duration or timeout: 92.06 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:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    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$24(ProtocolHandshake.java:359)
    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:362)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
    at gridtest.GridTest.GoogleTest(GridTest.java:49)
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Connect to 10.190.33.90:17946 [/10.190.33.90] failed: Connection timed out
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'usv-bmsapp-01.us.umuc.edu', ip: '10.190.32.186', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-696.23.1.el6.x86_64', java.version: '1.8.0_77'
Driver info: driver.version: unknown
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:117)
    at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:84)
    at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:68)
    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:535)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
    at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
    at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    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:317)
    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:110)
    at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:128)
    at org.seleniumhq.jetty9.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
    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:745)

1 个答案:

答案 0 :(得分:0)

您需要解决以下几个问题:

Selenium版本

  • 登录节点描述:

    • Selenium 版本:&#39; 3.12.0&#39;,修订版:&#39; 7c6e0b3&#39;,时间:&#39; 2018-05-08T15: 15:08.936Z&#39;
  • 登录控制台描述:

    • Selenium 版本:&#39; 3.6.0&#39;,版本:&#39; 6fbf3ec767&#39;,时间:&#39; 2017-09-27T15: 28:36.4Z&#39;

JDK版本

  • 登录节点描述:

    • java.version &#39; 1.8.0_144&#39;
  • 登录控制台描述:

    • java.version &#39; 1.8.0_77&#39;

节点启动命令

您用于注册节点的命令看起来像error-pront,如下所示:

java -jar -Dwebdriver.chrome.driver=chromedriver selenium-rver-standalone-3.12.0.jar -role node -nodeConfig node.json

应该是:

java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.12.0.jar -role node -nodeConfig node.json

解决方案

  • Selenium Grid Hub Selenium Grid Node 中的 JDK 升级到最近的级别JDK 8u171
  • Selenium Grid Hub 和_Selenium Grid Node_中的 Selenium客户端升级到当前级别Version 3.12.0
  • ChromeDriver 升级到当前ChromeDriver v2.38级别。
  • Chrome 版本保留在 Chrome v66.x 级别。 (as per ChromeDriver v2.38 release notes
  • 通过 IDE 清理您的项目工作区仅使用所需的依赖项重建项目
  • 使用CCleaner工具清除执行测试套件之前和之后的所有操作系统杂务。
  • 如果您的基本 Web客户端版本太旧,请通过Revo Uninstaller将其卸载并安装最新的GA和已发布的 Web客户端版本。
  • 进行系统重启
  • 执行@Test
  • 始终在driver.quit()方法中调用tearDown(){}以关闭&amp;正常销毁 WebDriver Web客户端实例。

nodeConfig

简单来说,您可以减少 nodeConfig ,即 node.json ,如下所示:

{
    "capabilities": [
        {
            "browserName": "firefox",
            "maxInstances": 5,
            "seleniumProtocol": "WebDriver"
        },
        {
            "browserName": "chrome",
            "maxInstances": 5,
            "seleniumProtocol": "WebDriver"
        },
        {
        "browserName": "internet explorer",
        "maxInstances": 1,
        "seleniumProtocol": "WebDriver"
        }
    ],
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 5,
        "port": 5566,
        "host": ip,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444,
        "hubHost": jenkins.us.abc.edu,
        "timeout":120,
        "browserTimeout":60
}