【问题标题】:selenium grid is not starting more than 5 sessionsselenium 网格不启动超过 5 个会话
【发布时间】:2018-01-16 13:56:29
【问题描述】:

我做了如下网格设置:

集线器: iMAC

开始于: java -jar 下载/selenium-server-standalone-2.52.0.jar -port 4444 -role hub

节点 1: Win8系统

开始于: java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.52.0.jar -role webdriver -hub http://192.168.1.103:4444/grid/register -nodeConfig Node1.json

节点 2: Win10系统

开始于: java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.52.0.jar -role webdriver -hub http://192.168.1.103:4444/grid/register -nodeConfig Node2.json

json的内容如下:

    {
  "capabilities":
      [
        {
          "browserName": "firefox",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "chrome",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "platform": "WINDOWS",
          "browserName": "internet explorer",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
        }
      ],
  "configuration":
  {
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 10,
    "port": 5557,
    "host": ip address of node1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": ip address of hub
  }
}

集线器和节点已正确启动。当我在套件 xml 中运行包含 20 个测试的 testng 套件时,thread-count="10"

我看到只触发了 5 个会话,

  • Node1 上 3
  • Node2 上的 2 个

预期/想要实现: 应该触发 10 个会话,每个节点上 5 个。

我尝试使用不同版本的 selenium 服务器独立设置相同的设置,但没有运气!!!

如果我做任何配置错误,请告诉我。

【问题讨论】:

    标签: automation automated-tests selenium-grid ios-ui-automation


    【解决方案1】:

    我无法重现您的问题。这就是我所拥有的。

    集线器开始使用命令:

    java -jar selenium-server-standalone-2.53.1.jar -role hub

    节点 #1 使用以下命令开始:

    java -jar selenium-server-standalone-2.53.1.jar -role node -nodeConfig nodev2.json

    节点 #2 使用以下命令开始:

    java -jar selenium-server-standalone-2.53.1.jar -role node -nodeConfig nodev2.json -port 5556

    节点配置文件nodev2.json的内容如下:

    {
        "capabilities": [
            {
                "browserName": "chrome",
                "maxInstances": 10,
                "seleniumProtocol": "WebDriver"
            }
        ],
        "configuration": {
            "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
            "maxSession": 10
        }
    }
    

    此时,我有一个具有 2 个节点的集线器,每个节点可以在任何给定时间点支持 10 个并发会话。

    我现在运行下面的 shell 脚本(它会尝试创建 21 个会话)。在第 21 次尝试创建新会话时,脚本将停止并且不会退出,因为第 21 次会话将进入 Hub 的等待队列。您可以通过打开 Grid 控制台确认消耗了 20 个 chrome 会话:http://localhost:4444/grid/console

    shell 脚本如下所示:

    #!/bin/bash
    counter=1
    for number in {1..21}
    do
        curl -i \
        -H "Accept: application/json" \
        -X POST -d '{"desiredCapabilities":{"browserName":"chrome"}}' \
        http://localhost:4444/wd/hub/session
        echo "Created session " $counter
        let counter++
    done 
    

    【讨论】:

    • 感谢 Krishnan,将尝试使用此 shell 脚本和节点配置 json。我将确认我是否能够启动 20 个并行会话。如果问题存在于 1. 我正在处理的框架 2. 网格设置中,这将缩小范围
    • 感谢 Krishnan,在看到 20 个 chrome 实例中,我的网格设置似乎按预期工作。将深入研究框架,我确信他们已经在某处编写了 TestNGRunner
    猜你喜欢
    • 2016-10-02
    • 2015-05-30
    • 1970-01-01
    • 2022-01-27
    • 2018-06-11
    • 1970-01-01
    • 2013-08-05
    • 2010-11-27
    • 1970-01-01
    相关资源
    最近更新 更多