title: Failed Parallel tests in C# with MbUnit framework and Selenium using Gallio and powershell with the Chrome Driver - all tests fail
body: <p>The Test solution has 2 projects - one Test project with the the test methods (it inherits from a base class which has the test steps written in detail) and the other Project is a Class library project which contains the commonly used methods and the actual steps of the tests.</p>
  
  <p>Using this solution to test data entry pages.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>When I execute the tests in parallel using Selenium Grid, all the tests fail - it opens up the Chrome browser and then nothing. </p>
  
  <p>The test report says that it the server timed out.</p>
  
  <p>When I run the tests sequentially they all pass (without Selenium Grid). </p>
  
  <p><strong>What I have done till now:</strong></p>
  
  <ol>
  <li>using Selenium Grid 2 </li>
  </ol>
  
  <p>1.1. to start the hub open command window (with admin access) and run the following command in the selenium directory:</p>
  
  <pre><code>    java -jar selenium-server-standalone-2.5.0.jar -role hub
  </code></pre>
  
  <p>1.2. open another instance of command window (with admin access) and run the following command in selenium directory:</p>
  
  <pre><code>    java -jar selenium-server-standalone-2.5.0.jar -Dwebdriver.chrome.driver=\chromedriver.exe -role wd -hub http://4444/grid/register&gt; 
  </code></pre>
  
  <p>2.execute the tests in powershell running the following:</p>
  
  <pre><code>    PS&gt;run-gallio test.dll
  </code></pre>
  
  <p>3.to use the chrome driver</p>
  
  <pre><code>    DesiredCapabilities capability = DesiredCapabilities.Chrome();
      capability.SetCapability(CapabilityType.BrowserName, "chrome");
      driver = new RemoteWebDriver(capability);
  </code></pre>
  
  <p>4.In the main test Project  in assemblyinfo.cs - have added the following attributes:</p>
  
  <pre><code>    [assembly: DegreeOfParallelism(4)]
      [assembly: Parallelizable(TestScope.All)]
  </code></pre>
  
  <p>5.For each class have attribute of Parallelizable and each test method also has the attribute of Parallelizable.</p>
  
  <p><strong>Some of what I have tried</strong></p>
  
  <ol>
  <li><p>set the browser binary location using DesiredCapabilities</p>
  
  <pre><code>DesiredCapabilities - capabilities.SetCapability("chrome.binary",this.binaryLocation); 
  </code></pre></li>
  </ol>
  
  <p>(<a href="https://stackoverflow.com/questions/15199545/remote-webdriver-chrome-throws-a-path-to-the-driver-executable-error">Remote Webdriver Chrome throws a &quot;path to the driver executable&quot; error</a>)
  This did not work for me.</p>
  
  <ol start="2">
  <li><p>set the chrome driver in the when invoking hub command 
  <a href="https://stackoverflow.com/questions/6921170/how-to-build-remote-webdriver-for-chrome">How to build remote Webdriver for Chrome</a>
  (This opens up the chrome browser but nothing after that)</p></li>
  <li><p>Also looked at this: <a href="https://stackoverflow.com/questions/6916029/selenium-grid2-howto-run-5-browsers-in-paralel">How to run multiple browsers on one hub using Selenium Grid2</a></p></li>
  <li><p>Tried multithreading also but that did not work (used ChromeDriver instead of RemoteWebDriver).</p></li>
  </ol>
  
  <p><strong>Error I get now</strong></p>
  
  <pre><code>Run-Gallio : [failed] Test/AddValue  Set Up
  OpenQA.Selenium.WebDriverException: Unexpected error. System.Net.WebException: Unable to connect to the remote server -
  --&gt; System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 4444
  at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
  at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6,Socket&amp; socket, IPAddress address, ConnectSocketState state, IAsyncResult asyncResult, Exception&amp; exception)    
  </code></pre>
  
  <p>What could the problem could be?</p>
  
  <p>What could I try within Selenium Grid? All guidance would be appreciated. </p>
  
  <p>cannot switch from selenium or C# to anything else. Thank you. </p>
  
  <p><strong>Edit:</strong>
  A few days later, using Selenium-server-2.41.0 and now getting the following timeout error message. </p>
  
  <pre><code>    OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4444/wd/hub/session/fdb51889-b9b7-4e97-beea-44dcf9637b0c/element/0/value timed out after 60 seconds. ---&gt; System.Net.WebException: The operation has timed out  
  </code></pre>
  
  <p>Added timeout span when calling the remotedriver for chrome 
          DesiredCapabilities capability = DesiredCapabilities.Chrome();
          driver = new RemoteWebDriver(capability);
          driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(120));</p>
  
  <p>this did not work. Any suggestions?</p>
  
  <p><strong>Edit</strong>
  Answer: Managed to solve the issue - There were errors on the page and due to network issues on my side - the pages were not fully loading and the script would search for the elements. Fixed this - Thank you Daniel and Faiz. </p>