1
votes

I'm running into an issue when using Selenium Grid and trying to register a node with a specific version of IE and then call the Grid Hub for an instance of that browser. My setup:

  • Selenium 3.0.1 with C# bindings
  • One class library defining my page objects/framework and one class library with my NUnit 3.5 tests
  • One VM running Server 2008 hosting a database and my Selenium Grid Hub, started with "java -jar C:\Selenium\selenium-server-standalone-3.0.1.jar -role hub -maxSession 20"
  • One VM running Windows 7 with IE9 with my webdriver node

I start my node with (line breaks added by me for readability, it's one line in the bat file):

java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe -jar C:\Selenium\selenium-server-standalone-3.0.1.jar -role webdriver -hub http://10.10.1.20:4444/grid/register -port 5566 -maxSession 20
-browser "browserName=internet explorer,version=9,maxInstances=1,platform=ANY,seleniumProtocol=WebDriver"
-browser "browserName=chrome,maxInstances=5"
-browser "browserName=firefox,maxInstances=5"

My code to call RemoteWebDriver is:

caps = new DesiredCapabilities();
caps.SetCapability("browserName", "internet explorer");
caps.SetCapability("version", "9");
WebDriver = new RemoteWebDriver(new System.Uri("http://10.10.1.20:4444/wd/hub"), caps);

When I run this code, when the code creates the new RemoteWebDriver the hub returns:

INFO - Got a request to create a new session: Capabilities [{browserName=internet explorer, version=9}]

Visual Studio then shows the following error returned:

System.InvalidOperationException : Error forwarding the new session cannot find : Capabilities [{browserName=internet explorer, version=9}] TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

I've tried setting the node and my code to use "9.0" instead of "9" and setting the browserName to "iexplore" instead of "internet explorer" as some posts I've found online suggested, with no success. I've spent two hours digging through Google and through the Selenium docs but no one seems to even have an enumeration of the format expected for the "version" capability for various browsers, so I can't even be sure I'm using the right values. If I remove the version flag from the node startup batch and the setCapability call to version in my C# code, the browser launches fine. However, I'm going to have a grid with multiple IE variants for testing and need to be able to specify which version of IE I want. Can anyone assist me in the right way to launch a node for a specific version of IE, register that node to a hub, and call into it with a RemoteWebDriver?

1

1 Answers

1
votes

I found a solution - while I was unable to obtain a version-specific instance of IE using the command line arguments, I was able to do so using JSON-based configuration. I now launch my Selenium Grid Node using the following:

java -Dwebdriver.ie.driver=C:\SeleniumGrid\IEDriverServer.exe -Dwebdriver.chrome.driver=C:\SeleniumGrid\chromedriver.exe -jar C:\SeleniumGrid\selenium-server-standalone-3.0.1.jar -role webdriver -nodeConfig "C:\SeleniumGrid\NodeIE9.json"

And my NodeIE9.json file contains the following:

{
  "capabilities":
  [

    {
      "browserName": "firefox",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "internet explorer",
      "version": "9",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 11,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://10.10.1.20:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

I saw a suggestion somewhere that mentioned that the "version" property needed to be a string and not an int in the JSON, so maybe the argument passed in via command line is being interpreted incorrectly? Either way, this works very well and I prefer configuring the node with JSON over command line args anyways. It's cleaner.