title: Selenium runs as scheduled task on Windows Server
body: <p>We have an application where we use the Selenium test framework. The application runs on Windows Server 2012 and runs regularly through Windows Task Scheduler. I connect to the server through Remote Desktop. </p>
  
  <p>The problem occurs when I set in the scheduled task set-up option "Run whether user is logged on or not". My application starts to run properly with this javascript code but then it ends immediately with error exception - it is marked on the line below. If I start the application normally, everything works fine. Unfortunately, I need to make an application which can run even when no one is logged on.  Hasn´t anyone already met with this problem?</p>
  
  <p>This is my code:</p>
  
  <pre><code>public Bitmap MakeBitmap(Uri url)
  {
      driver = MakeFirefoxDriver();
      driver.Navigate().GoToUrl(url.AbsoluteUri);
  
      // In this command, an exception occurs.
      driver.ExecuteScript("document.body.style.overflow = 'hidden'")
  
      Thread.Sleep(TimeSpan.FromSeconds(SleepTime));
      var screenshot = driver.GetScreenshot();
      return new Bitmap(Image.FromStream(new MemoryStream(screenshot.AsByteArray)));
  }
  
  private FirefoxDriver MakeFirefoxDriver() 
  {
      var profile = new FirefoxProfile { EnableNativeEvents = true };
      var capabilityValue = new List&lt;string&gt; { "-width", "500", "-height", "340" };
      var capabilities = DesiredCapabilities.Firefox();
      capabilities.SetCapability("initial", capabilityValue);
      capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile);
      return new FirefoxDriver(capabilities);
  }
  </code></pre>
  
  <p>Exception looks like this:</p>
  
  <pre><code>Exception log: No response from server for url http://localhost:7062/hub/session/......
  StackTrace: at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest
  request) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
  driverCommandToExecute, Dictionary`2 parameters) at ...
  </code></pre>