title: C# Selenium Firefox NullReferenceException WebDriverException
body: <p>I've just rebuilt my development machine and I'm now having issues running Selenium tests.  I know there's an issue with my setup as when I push new code and tests to the build server, they pass without problem.  The tests used to pass without problem before the rebuild on this machine too.  I've reduced my test case to the simplest possible in order to try and isolate the error.</p>
  
  <ul>
  <li>Firefox: 21.0 (Also produces the same behaviour with Firefox 22.0 &amp; 23.0)</li>
  <li>NuGet packages: Selenium.WebDriver 2.40.0 &amp; Selenium.Support 2.40.0</li>
  <li>Visual Studio 2010 SP1.</li>
  </ul>
  
  <p>My site test site is a local ASP.NET MVC site and responds to requests in less than 200ms.</p>
  
  <p>My simple failing case is as follows, attempting to login:</p>
  
  <pre><code>using OpenQA.Selenium.Firefox;
  using OpenQA.Selenium;
  using System.Threading;
  class Program
  {
      static void Main(string[] args)
      {
          FirefoxDriver driver = new FirefoxDriver();
          try
          {
              driver.Navigate().GoToUrl("http://test.mysite.com/Account/Login/");
              driver.FindElement(By.Name("UserName")).SendKeys("AdminUser");
              driver.FindElement(By.Name("Password")).SendKeys("AdminPassword");
              driver.FindElement(By.Id("log-in-btn")).Click();
          }
          finally
          {
              driver.Quit();
          }
      }
  }
  </code></pre>
  
  <p>The problem is it doesn't always fail and it doesn't always fail in the same place.  Some runs all the commands will execute.  At other times any of the FindElement lines will fail with the following errors:</p>
  
  <p>NullReferenceException Object reference not set to an instance of an object at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)</p>
  
  <p>WebDriverException The HTTP request to the remote WebDriver server for URL <code>http://localhost:7055/hub/session/eff6f0c7-84e1-451d-adc8-1f02324d08ae/element</code> timed out after 60 seconds. at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)</p>
  
  <p>Even when the test raises one of the above errors after a while sat there doing nothing the test browser remains responsive and one can manually complete the tests.</p>
  
  <p>I'm really tearing my hair out over this.  In the past couple of days I've tried many different combinations, e.g. different Firefox versions, switching to Chrome, switching back to Selenium.WebDriver 2.39.0 all with the same results.</p>
  
  <p>I realise this is quite a popular error for Selenium but I'm hoping this simple test case may assist in tracking down what's causing this specific version of it.</p>