硒网格开始的会话数不超过5个 [英] selenium grid is not starting more than 5 sessions

查看:87
本文介绍了硒网格开始的会话数不超过5个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照以下步骤完成了网格设置:

枢纽:iMAC

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

Started with: java -jar Downloads/selenium-server-standalone-2.52.0.jar -port 4444 -role hub

Node1: 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

Started with: 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

Node2: 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

Started with: 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的内容如下:

The contents of the json is as follows:

    {
  "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套件时,线程计数为"10"

Hub and nodes are started correctly. When i run a testng suite with 20 tests in the suite xml, with thread-count="10"

我看到只有5个会话被触发,

I see only 5 sessions are triggered,

  • 节点1上的3
  • 2在Node2上

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

Expected/Want to achieve: 10 sessions should be triggered, 5 on each nodes.

我尝试了不同版本的selenium服务器的相同设置,但是没有运气!!!

I tried the same setup with different versions of selenium server standalone, no luck though!!!

如果我在配置上有任何错误,请告诉我.

Please let me know if i'm doing any configuration mistakes.

推荐答案

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

I haven't been able to reproduce your problem. Here's what I have.

Hub开始使用以下命令:

Hub started using the command :

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

节点#1使用以下命令启动:

Node #1 started using the command :

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

节点#2使用以下命令启动:

Node #2 started using the command :

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

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

The contents of the node configuration file nodev2.json is as below :

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

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

At this point, I have a hub which has 2 nodes and each of the nodes can support 10 concurrent sessions at any given point in time.

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

I now run the below shell script (which would try to create 21 sessions). The script will stall and not exit, at the 21st attempt of creating a new session, because the 21st session is going to go into the Hub's waiting queue. You can confirm that there are 20 chrome sessions consumed by opening up the Grid console : http://localhost:4444/grid/console

shell脚本如下所示:

The shell script can look like below :

#!/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 

这篇关于硒网格开始的会话数不超过5个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆