我使用下面的命令来启动 Node,我可以看到当 testNG 套件中的线程数大于 1 时,会并行启动多个浏览器实例。请注意,我没有使用计算机中安装的 Firefox 浏览器,而是复制 Firefox 二进制文件并使用相同的文件进行测试。另外,一旦测试开始运行,我可以看到配置有“maxSessions=1”,但仍然有多个测试在浏览器的并行实例中运行。
java -jar ${jarLocation} -role webdriver -hub ${hubRegisterURL} -port ${port} -log ${gridNodeLog} -maxSession 1
请帮忙......!
最佳答案
尝试:
-browser browserName=firefox,maxSession=1,maxInstances=1,platform=LINUX
您可以启动使用 JSON 配置文件配置的网格节点
$ java -jar selenium-server-standalone.jar -role node -nodeConfig node1Config.json
这是一个 nodeConfig.json 文件的示例:
{
"capabilities": [
{
"browserName": "firefox",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": false,
"firefox_profile": "",
"browser-version": "27",
"platform": "WINDOWS",
"maxInstances": 1,
"firefox_binary": "",
"cleanSession": true
}
],
"configuration": {
"_comment" : "Configuration for Node",
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.WebDriverRemoteProxy",
"port": 5555,
"host": ip,
"register": true,
"hubPort": 4444,
"maxSessions": 1
}
}
关于java - 无法使用 Selenium 网格中的 maxSession 将浏览器 session 限制为 1 (Java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50403554/