无法使用Selenium打开五个以上的Chrome浏览器

时间:2012-08-01 18:57:29

标签: selenium webdriver selenium-grid selenium-chromedriver

我启动了集线器和节点:

java -jar C:\...\selenium-server-standalone-2.25.0.jar -role hub
java -jar C:\...\selenium-server-standalone-2.25.0.jar -role node 
    -hub http://localhost:4444/grid/register 
    -browser browserName=chrome,maxInstances=6,platform=WINDOWS 
    -timeout 0
    -Dwebdriver.chrome.driver=c:\...\chromedriver.exe

然后,我创建了Chrome驱动程序实例:

    Dim desiredCapabilities As Remote.DesiredCapabilities = Remote.DesiredCapabilities.Chrome()
    Dim size As String = "--window-size={0},{1}"
    size = String.Format(size, browserWidth, browserHeight)
    Dim position As String = "--window-position={0},{1}"
    position = String.Format(position, browserWidth * index, 0)
    desiredCapabilities.SetCapability("chrome.switches", {size, position})
    driver = New Remote.RemoteWebDriver(New System.Uri("http://localhost:4444/wd/hub"), desiredCapabilities)

五件作品很好。第六次等待Selenium回应。这是错误:

OpenQA.Selenium.WebDriverException: No response from server for url http://localhost:4444/wd/hub/session. Aborting test execution.

节点中没有活动,因此集线器似乎没有将第六个请求分配给节点。我需要的是maxInstances=6以外的设置吗?

1 个答案:

答案 0 :(得分:1)

我尝试在每个五个浏览器的不同端口上运行单独的节点,并且它可以工作:

集线器:

java -jar C:\...\selenium-server-standalone-2.25.0.jar -role hub

前五:

java -jar C:\...\selenium-server-standalone-2.25.0.jar -role node -port 5555
    -hub http://localhost:4444/grid/register 
    -browser browserName=chrome,maxInstances=5,platform=WINDOWS 
    -timeout 0
    -Dwebdriver.chrome.driver=c:\...\chromedriver.exe

接下来五:

java -jar C:\...\selenium-server-standalone-2.25.0.jar -role node -port 5556
    -hub http://localhost:4444/grid/register 
    -browser browserName=chrome,maxInstances=5,platform=WINDOWS 
    -timeout 0
    -Dwebdriver.chrome.driver=c:\...\chromedriver.exe