转发新会话时出错:Selenium Grid 2

时间:2015-03-03 22:00:43

标签: selenium selenium-webdriver webdriver selenium-grid remotewebdriver

我从here获取了最新的Selenium Server,即2.45.0。遵循文档并使用以下命令启动集线器

java -jar selenium-server-standalone-2.45.0.jar -role hub -hubConfig HubConfigFile.json

并且,JSon文件内容为:

{
  "host": 10.5.0.21,
  "port": 4444,
  "newSessionWaitTimeout": -1,
  "servlets" : [],
  "prioritizer": null,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 5000,
  "cleanUpCycle": 5000,
  "timeout": 300000,
  "browserTimeout": 0,
  "maxSession": 5,
  "jettyMaxThreads":-1
}

并且唯一的Node

java -jar selenium-server-standalone-2.45.0.jar -role node -nodeConfig DefaultNode.json

{
  "capabilities":
      [
        {
          "browserName": "*firefox",
          "maxInstances": 5,
          "seleniumProtocol": "Selenium"
        },
        {
          "browserName": "*googlechrome",
          "maxInstances": 5,
          "seleniumProtocol": "Selenium"
        },
        {
          "browserName": "*iexplore",
          "maxInstances": 1,
          "seleniumProtocol": "Selenium"
        },
        {
          "browserName": "firefox",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "chrome",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "internet explorer",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
        }
      ],
  "configuration":
  {
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 5,
    "port": 5555,
    "host": 10.5.0.161,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": 10.5.0.21
  }
}

到目前为止,一切看起来都很棒。注册here

后,请查看控制台的屏幕截图

而且,当我尝试开始测试时,问题就开始了:

DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
capabilities.SetCapability("browserName", "internet explorer");
capabilities.SetCapability("platform", "XP");
capabilities.SetCapability("version", "8.0");
//capabilities.SetCapability("seleniumProtocol", "WebDriver");

Driver = new RemoteWebDriver(new Uri("http://10.5.0.21:4444/wd/hub"), capabilities);

而且,它抛出:

  

WebDriver.dll中出现“System.InvalidOperationException”类型的异常,但未在用户代码中处理

     

其他信息:转发新会话时出错无法找到:功能[{browserName = internet explorer,version = 8.0,platform = XP}]

查看屏幕截图screenshot 1 screenshot 2 screenshot 3

我必须说Selenium Grid上的文档非常令人沮丧。我花了一整天的时间试图弄清楚出了什么问题。

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

经过大量的研究,我能够解决这个问题。命令行参数错误,因为我使用WebDriver我必须替换

java -jar selenium-server-standalone-2.45.0.jar -role node -nodeConfig DefaultNode.json

java -jar selenium-server-standalone-2.45.0.jar -role webdriver -nodeConfig DefaultNode.json -Dwebdriver.ie.driver=.\IEDriverServer.exe

确保我在正确的目录中设置驱动程序可执行文件。