Selenium Grid:MaxSessions vs MaxInstances

Chr*_*rke 60 selenium selenium-grid selenium-webdriver

我想知道是否有人可以对一个Selenium让我们有点头疼的问题有所了解.

我们困惑的意义MaxSessionMaxInstances硒电网.我们认为这MaxSession是可以在单个节点上运行的测试会话的总数.我们还认为MaxInstances测试可以打开的浏览器总数.

或者是MaxInstances节点可用的浏览器总数?

我们使用的命令是:

java -Xrs -jar selenium-server.jar -role node -port 44506 -hub http://localhost:44500
/grid/register -firefoxProfileTemplate SeleniumProfile -timeout 300000 -browser 
"browserName=firefox,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver" -browser 
"browserName=chrome,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver"
Run Code Online (Sandbox Code Playgroud)

我们认为我们使用节点的方式(上面)默认是5个并发测试会话.

每个测试都有20个可用的浏览器吗?

或者每个测试会话是否共享池中的20个浏览器(10 chrome/10 FF) - 与其他测试会话?

Anu*_*ony 113

好问题....我会说它有点令人困惑....但是会尝试用简单的方式回答它.

MaxInstances这说......相同版本的浏览器可以在远程系统上运行多少个实例.

For example, i have a FF12,IE and i declared the command as follows
-browser browserName=firefox,version=12,maxInstances=5,platform=LINUX
-browser browserName=InternetExplorer,version=9.0,maxInstances=5,platform=LINUX
Run Code Online (Sandbox Code Playgroud)

所以我可以在远程机器上同时运行5个Firefox 12实例和5个IE9实例.因此,总用户可以并行运行10个不同浏览器的实例(FF12和IE9).

MaxSession这说......在远程系统中,一次可以并行运行多少个浏览器(任何浏览器和任何版本).因此,这将覆盖Max Instances设置,并可以限制可以并行运行的浏览器实例的数量.

For above example, when maxSession=1 forces that you never have more than 1 browser running. 

With maxSession=2 you can have 2 Firefox tests at the same time, or 1 Internet Explorer and 1 Firefox test). 
Run Code Online (Sandbox Code Playgroud)

无论您定义了什么MaxInstances.

有关更清晰的信息,请访问 - https://seleniumhq.github.io/docs/grid.html


Pix*_*ter 6

为了扩展Anuragh27crony 的答案,我绘制了一个快速图表:

在此输入图像描述

如果这是您的节点配置,那么您最多可以并行执行 5 个测试,例如以下组合:

  • 3 * 铬,2 * 火狐
  • 2 * 铬、2 * 火狐、1 * 边缘
  • 5 * 边缘
  • 3 * 镀铬

以下组合是不可能的:

  • 4 * chrome(超过 Chrome maxInstances)
  • 6 * 边缘(超过 maxSessions)
  • 3 * chrome、3 * firefox(超过 maxSessions)

正如 Anuragh 提到的,MaxInstances 适用于特定浏览器,而 MaxSessions 适用于整个节点。