title: Simple Selenium Test Gives XHR ERROR : 404
body: <p>I'm using selenium-rc with C# to test my asp.net mvc2 application. Currently all I am doing is opening the home page with selenium RC.</p>
  
  <p>when I run my test I see the selenium remote control open in a browser and I see my application open correctly in a browser but selenium shows a 404 error and aborts the test.</p>
  
  <p>In an attempt to get this working I have cut the test down to a simple console app and have changed the default selenium port here is my code:</p>
  
  <pre><code>static void Main(string[] args)
      {
          try
          {
              var _selenium = new DefaultSelenium("localhost", 1234, "*chrome", "http://localhost:6666");
              _selenium.Start();
              _selenium.Open("/");
  
              try
              {
                  _selenium.Stop();
              }
              catch (Exception)
              {
                  // Ignore errors if unable to close the browser
              }
  
          }
          catch (Exception e)
          {
              Console.WriteLine(e);
          }
          Console.WriteLine("Done.");
          Console.ReadKey();
  
      }
  </code></pre>
  
  <p>this fails with the error <strong>"XHR ERROR: URL = /localhost:6666/ Response_Code = 404 Error_Message = Not Found on session 5f2e59798ae74e7cb741d50cae7e817a"</strong></p>
  
  <p>and if you look in the running selenium console you see</p>
  
  <pre><code>15:53:16.238 INFO - Allocated session 5f2e59798ae74e7cb741d50cae7e817a for http://localhost:6666, launching...
  15:53:16.265 INFO - Preparing Firefox profile...
  15:53:18.325 INFO - Launching Firefox...
  15:53:20.977 INFO - Got result: OK,5f2e59798ae74e7cb741d50cae7e817a on session 5f2e59798ae74e7cb741d50cae7e817a
  15:53:20.980 INFO - Command request: open[/, ] on session 5f2e59798ae74e7cb741d50cae7e817a
  15:53:22.654 INFO - Got result: XHR ERROR: URL = http://localhost:6666/ Response_Code = 404 Error_Message = Not Found on session 5f2e59798ae74e7cb741d50cae7e817a
  </code></pre>
  
  <p>Interesting things that I have tried are:  </p>
  
  <p>change the site to "google" - then my test works<br>
  change the site to "google" port 80 then it doesnt work.<br>
  moved my site from cassini to iis 7 - didnt work<br>
  made my site the default site on iis 7 eg <a href="http://localhost/" rel="nofollow">http://localhost/</a> - didnt work<br>
  I've used fiddler to watch the session - all requests fired return successfully.<br>
  I've tried passing -avoidProxy and -ensureCleanSession when starting the RC server. Hasn't made any noticable difference.</p>
  
  <p>If I reconfigure selenium to use the default port I get the following exception repeated over and over (once every 10 seconds / different sessionid each time). This doesn't happen once I've changed the default port but i've included it just in case.</p>
  
  <pre><code>16:26:38.019 WARN - POST /selenium-server/driver/?seleniumStart=true&amp;localFrameAddress=top&amp;seleniumWindowName=&amp;uniqueId=sel_48694&amp;sessionId=a87b8d6a9e444a5485a5044ef6370e2d&amp;counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1286810798016&amp;sequenceNumber=4115 HTTP/1.1
  java.lang.RuntimeException: sessionId a87b8d6a9e444a5485a5044ef6370e2d doesn't exist; perhaps this session was already stopped?
      at org.openqa.selenium.server.FrameGroupCommandQueueSet.getQueueSet(FrameGroupCommandQueueSet.java:220)
      at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleBrowserResponse(SeleniumDriverResourceHandler.java:165)
      at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:131)
      at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
      at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
      at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
      at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
      at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
      at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
      at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:245)
      at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
      at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
  </code></pre>
  
  <p>Can anybody shed some light?</p>