Selenium Grid:同一台PC中的2个节点

时间:2013-12-26 19:30:50

标签: c# selenium-grid

我遇到了Selenium Remote Server作为网格的问题。我正在测试应用程序和计算机,我启动服务器和4个节点,一个用于FireFox,一个用于Chrome,另一个用于Internet Explorer,最后一个用于HtmlUnit。

当我选择FireFox或HtmlUnit时没有问题。但是对于Chrome和IE,它取决于我们首先启动的是哪一个。我们首先启动的节点是运行的节点。

我在C#中使用selenium RemoteWebDriver。代码是:

if (browserId == 1)
  webDriver = new RemoteWebDriver(new Uri(Properties.Settings.Default.HubUri),
                                          DesiredCapabilities.HtmlUnit());
else if (browserId == 2)
  webDriver = new RemoteWebDriver(new Uri(Properties.Settings.Default.HubUri), 
                                          DesiredCapabilities.Firefox());
else if (browserId == 3)
  webDriver = new RemoteWebDriver(new Uri(Properties.Settings.Default.HubUri), 
                                  DesiredCapabilities.InternetExplorer());
else if (browserId == 4)
  webDriver = new RemoteWebDriver(new Uri(Properties.Settings.Default.HubUri), 
                                  DesiredCapabilities.Chrome());

我使用以下命令行启动了服务器:

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

节点:

java -jar selenium-server-standalone-2.38.0.jar -Dwebdriver.ie.driver="C:\Utilities\Grid\IEdriverServer.exe" -role node -hub http://"localhost":4444/grid/register -port 5559
java -jar selenium-server-standalone-2.38.0.jar -role node -hub http://"localhost":4444/grid/register -port 5557
java -jar selenium-server-standalone-2.38.0.jar -Dwebdriver.chrome.driver="C:\Utilities\Grid\chromedriver.exe" -role node -hub http://"localhost":4444/grid/register -port 30000
java -jar selenium-server-standalone-2.38.0.jar -role node -hub http://"localhost":4444/grid/register -browser browserName=htmlunit -port 5558

我想知道一切是否正确以及是否可以在同一台PC上运行这些节点。

我正在使用Firefox,Intermet Explorer,Chrome和HtmlUnit。与Chrome和Internet Explorer存在冲突。

BrowsersConfiguration:

port:5559
servlets:[]
host:localhost
cleanUpCycle:5000
browserTimeout:0
hubHost:localhost
Dwebdriver.ie.driver=C:\Utilities\Grid\IEdriverServer.exe:
registerCycle:5000
hub:http://localhost:4444/grid/register
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout:-1
url:http://"localhost":5559
remoteHost:http://"localhost":5559
prioritizer:null
register:true
throwOnCapabilityNotPresent:true
nodePolling:5000
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
maxSession:5
role:node
hubPort:4444
timeout:300000

DefaultRemoteProxy (version : 2.38.0)
id : http://"localhost":5557, OS : VISTA
BrowsersConfiguration
port:5557
servlets:[]
host:"localhost"
cleanUpCycle:5000
browserTimeout:0
hubHost:localhost
registerCycle:5000
hub:http://localhost:4444/grid/register
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout:-1
url:http://"localhost":5557
remoteHost:http://"localhost":5557
prioritizer:null
register:true
throwOnCapabilityNotPresent:true
nodePolling:5000
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
maxSession:5
role:node
hubPort:4444
timeout:300000

DefaultRemoteProxy (version : 2.38.0)
id : http://"localhost":30000, OS : VISTA
BrowsersConfiguration
port:30000
servlets:[]
host:"localhost"
cleanUpCycle:5000
browserTimeout:0
hubHost:localhost
registerCycle:5000
hub:http://localhost:4444/grid/register
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout:-1
url:http://"localhost":30000
remoteHost:http://"localhost":30000
prioritizer:null
register:true
throwOnCapabilityNotPresent:true
nodePolling:5000
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
maxSession:5
role:node
Dwebdriver.chrome.driver=C:\Utilities\Grid\chromedriver.exe:
hubPort:4444
timeout:300000

DefaultRemoteProxy (version : 2.38.0)
id : http://"localhost":5558, OS : VISTA
BrowsersConfiguration
port:5558
servlets:[]
host: "localhost"
cleanUpCycle:5000
browserTimeout:0
hubHost:localhost
registerCycle:5000
hub:http://localhost:4444/grid/register
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout:-1
url:http://"localhost":5558
remoteHost:http://"localhost":5558
prioritizer:null
register:true
throwOnCapabilityNotPresent:true
nodePolling:5000
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
browser:browserName=htmlunit
maxSession:5
role:node
hubPort:4444
timeout:300000

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

我不明白为什么你需要在同一台PC上运行4个不同的节点。如果您在该PC上运行一个网格节点,它将支持运行您需要的所有实例。一个Grid节点可以执行多种类型的多个浏览器。你有什么理由不这么想吗?只有我能想到的另一个原因是你是否试图在不同的Linux xvfb会话中运行这些独立的浏览器?