title: Selenium RemoteWebDriver c# - System.InvalidOperationException
body: <p>I have a sample UI test project using v3.4.0 of Selenium.WebDriver.</p>
  
  <p>Everything works fine when I run the tests against a local driver but I want to get things working using Selenium Grid 2.</p>
  
  <p>As soon as I try to instantiate a new RemoteWebDriver I get an exception with little detail.</p>
  
  <pre><code>Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);     
  </code></pre>
  
  <p>Note: GridUrl is "<a href="http://localhost:4444/wd/hub" rel="noreferrer">http://localhost:4444/wd/hub</a>"</p>
  
  <p>Throws a System.InvalidOperationException with StackTrace as follows:</p>
  
  <pre><code>   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
     at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
     at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
     at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
     at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
     at xxxx.Ui.Tests.SeleniumTests.TestInitialize() in C:\Users\xxxx\Documents\Visual Studio 2015\Projects\xxxx.Ui.Tests\xxxx.Tests\PersonTests.cs:line 38
  </code></pre>
  
  <h2><strong>Hub configuration</strong></h2>
  
  <p>I have v3.4.0 of the hub running locally with the following configuration:</p>
  
  <pre><code>{
    "port": 4444,
    "newSessionWaitTimeout": -1,
    "servlets" : [],
    "withoutServlets": [],
    "custom": {},
    "capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
    "throwOnCapabilityNotPresent": true,
    "cleanUpCycle": 5000,
    "role": "hub",
    "debug": false,
    "browserTimeout": 0,
    "timeout": 1800
  }
  </code></pre>
  
  <p>Hub started with:</p>
  
  <blockquote>
    <p>java -jar selenium-server-standalone-3.4.0.jar -role hub</p>
  </blockquote>
  
  <p>This has come up OK and looks to be running.
  <a href="https://i.stack.imgur.com/lCWh7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lCWh7.png" alt="working hub console"></a></p>
  
  <h2><strong>Node configuration</strong></h2>
  
  <p>I have tried a number of nodes (chromedriver.exe, IEDriverServer.exe and geckodrvier.exe). None of these work with the RemoteWebDriver. All of them are in a directory that has been added to my system PATH variable.</p>
  
  <h2><strong>Chrome config</strong></h2>
  
  <pre><code>{
    "capabilities":
    [
      {
        "browserName": "chrome",
        "maxInstances": 5,
        "seleniumProtocol": "WebDriver"
      }
    ],
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 5,
    "port": 5556,
    "register": true,
    "registerCycle": 5000,
    "hub": "http://localhost:4444",
    "nodeStatusCheckTimeout": 5000,
    "nodePolling": 5000,
    "role": "node",
    "unregisterIfStillDownAfter": 60000,
    "downPollingLimit": 2,
    "debug": false,
    "servlets" : [],
    "withoutServlets": [],
    "custom": {}
  }
  </code></pre>
  
  <p>Node started with:</p>
  
  <blockquote>
    <p>java -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig chromeNodeConfig.json</p>
  </blockquote>
  
  <p>The other node configs are largely the same except for the different browser names and ports.</p>
  
  <p>Once all nodes are started, the console looks as follows:
  <a href="https://i.stack.imgur.com/4QnXe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4QnXe.png" alt="console with nodes running"></a></p>
  
  <p>I'm not able to get much from the exception. Is it a versioning issue of the drivers I have? I have tried customising my DesiredCapabilities to ensure I'm matching those in the node config. All of that looks fine.</p>
  
  <hr>
  
  <h2><strong>Update</strong></h2>
  
  <p>As requested I'm adding a bit more detail as to how I'm trying to launch a browser. None of the browsers work with the RemoteWebDriver whereas they do with the local drivers. Showing the Chrome example - only difference between each is regarding the Capabilities that I'm passing in to the base class constructor.</p>
  
  <p>In my test class</p>
  
  <pre><code>[TestClass]
  public class PersonTests : PersonTestBase
  {
      public PersonTests() 
          : base(DesiredCapabilities.Chrome())
      {
      }
  
      [TestCategory("Chrome")]
      [TestMethod]
      public void Chrome_ShouldCreatePlacement()
      {
          this.ShouldCreatePerson();
      }        
  }
  </code></pre>
  
  <p>In my base class I am doing the following</p>
  
  <pre><code>public abstract class PersonTestBase
  {
      protected IWebDriver Driver;
      protected ICapabilities Capabilities;
      protected string TargetUrl;
      protected string GridUrl;
  
      protected PersonTests(ICapabilities capabilities)
      {
          this.Capabilities = capabilities;
      }
  
      [TestInitialize]
      public void TestInitialize()
      {
          TargetUrl = "http://urlOfMyWebsite";
          GridUrl = "http://localhost:4444/wd/hub"
  
          Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);            
      }
  
      [TestCleanup]
      public void TestCleanup()
      {
          Driver.Quit();
      }
  
      protected void ShouldCreatePerson()
      {
          Driver.Navigate().GoToUrl(TargetUrl);
  
          //rest of test code ommitted
      }
  }
  </code></pre>