【问题标题】:Docker selenium gird unable to connect our client URLDocker selenium 网格无法连接您的客户端 URL
【发布时间】:2018-11-26 14:10:25
【问题描述】:

我们有一个自动化脚本,它在 jenkins 和 docker 的网格中运行。 因此,当我们尝试运行 selenium 代码时,它会连接到网格节点 chrome 或 ff,然后在 selenium java 代码的基础上执行。

这一切都发生在安装了 docker 的 linux 服务器上,我们有四个容器——Jenkins、Selenium 网格、chrome 节点和 ff 节点。

但是当我尝试从 jekins 运行作业时,它会失败并给出以下错误-

runners.TestRunner > Scenario: Extract the Report.classMethod FAILED
org.openqa.selenium.remote.UnreachableBrowserException
Caused by: java.net.NoRouteToHostException
org.openqa.selenium.remote.UnreachableBrowserException
Caused by: java.net.NoRouteToHostException
org.openqa.selenium.remote.UnreachableBrowserException
Caused by: java.net.NoRouteToHostException

现在,当我不从 docker 设置运行它并从 IntelliJ 执行它时,同样可以正常工作。

private WebDriver createSTAGEDriver() throws MalformedURLException {
        switch (driverType) {
            case GridChrome :
                DesiredCapabilities cap = DesiredCapabilities.chrome();
                cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
                driver = new RemoteWebDriver(new URL("http://xx.xx.xxx.xxxx:xxxxx/wd/hub"),cap);
                break;

无法找出问题所在。

任何帮助将不胜感激。

【问题讨论】:

    标签: docker jenkins selenium-chromedriver selenium-grid


    【解决方案1】:

    这是固定的,

    createSTAGEDriver 函数中的实际而不是 IP,我需要提及在我的 docker .yml 文件中定义的 ip 的名称

    version: '2'
    services:
     hub:
       restart: always
       image: selenium/hub:3.14
       ports:
         - "4444:4444"
       networks:
         - "selenium-grid_default"
     firefox:
       restart: always
       image: selenium/node-firefox:3.5
       environment:
        - HUB_PORT_4444_TCP_ADDR=hub
        - HUB_PORT_4444_TCP_PORT=4444
        - NODE_MAX_INSTANCES=2
        - NODE_MAX_SESSION=2
       links:
        - "hub"
    

    所以基本上我需要使用链接中定义的这个集线器而不是 ip。

    【讨论】:

      猜你喜欢
      • 2015-07-09
      • 2019-09-29
      • 1970-01-01
      • 1970-01-01
      • 2011-09-19
      • 2021-06-24
      • 2020-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多