如何在单个Selenium webdriver节点中运行多个浏览器(Firefox,IE,Chrome)。
尝试使用2个浏览器(Firefox,IE或Firefox,chrome)执行以下命令,并且成功了,
java -jar selenium-server-standalone-2.39.0.jar -Dwebdriver.ie.driver="C:\IEDriverServer.exe" -role node -hub http://x.x.x.x:5678/grid/register -browser "browserName=firefox,setjavascriptEnabled=true,acceptSslCerts=true,maxInstances=5,platform=WINDOWS" -browser "browserName=internet explorer,setjavascriptEnabled=true,acceptSslCerts=true,platform=WINDOWS"
但是当使用3个浏览器调用时,如下所示,测试失败并出现tcl错误
Error: org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup {javascriptEnabled=true, acceptSslCerts=true, browserName=internet explorer}
java -jar selenium-server-standalone-2.39.0.jar -Dwebdriver.ie.driver="C:\IEDriverServer.exe" -Dwebdriver.chrome.driver="C:\chromedriver.exe"-role node -hub http://x.x.x.x:5678/grid/register -browser "browserName=firefox,setjavascriptEnabled=true,acceptSslCerts=true,maxInstances=5,platform=WINDOWS" -browser "browserName=internet explorer,setjavascriptEnabled=true,acceptSslCerts=true,platform=WINDOWS" -browser "browserName=chrome,setjavascriptEnabled=true,acceptSslCerts=true,platform=WINDOWS"
如何解决问题,我们不能多次提供-Dwebdriver参数?
提前致谢。
答案 0 :(得分:2)
使用您自己的自定义节点配置,而不是通过它:
java -jar selenium-server-standalone-2.39.0.jar -Dwebdriver.ie.driver="C:\IEDriverServer.exe" -role node -hub http://x.x.x.x:5678/grid/register -nodeConfig config.json
{
"capabilities":
[
{
"browserName": "firefox",
"version": "3.6",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "internet explorer",
"version": "8",
"platform": "WINDOWS",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"localhost",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":XXXXX,
}
}
maxSession:XXXXX
是关键。这将告诉节点它可以同时激活多少个会话。