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

Error forwarding the new session: Selenium Grid 2

我从 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);

并且,它抛出:

An exception of type 'System.InvalidOperationException' occurred in WebDriver.dll but was not handled in user code

Additional information: Error forwarding the new session cannot find : Capabilities [{browserName=internet explorer, version=8.0, platform=XP}]

查看截图screenshot 1 screenshot 2 screenshot 3

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

我是不是漏掉了什么?

经过大量研究,我终于解决了这个问题。命令行参数错误,因为我正在使用 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

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