title: How to execute concurrent tests with Selenium WebDriver on a single machine?
body: <p>My goal is to run multiple tests on a single machine in parallel. For that I'm using Selenium WebDriver with Firefox and Mbunit.  Unfortunately it looks like like driver creation in Selenium is not thread safe and I have to wrap this part of the code with global lock. This is not the end of the world but my question is if this is all I need to do or maybe there are other parts that need synchronization? Another option would be to have AppDomain or Process isolation in MBUnit but I'm not sure if this is implemented.</p>
  
  <pre><code> [TestFixture]
  [Parallelizable]
  public class Class1
  {
  
      public static object padlock = new object();
  
      [Test]
      [Parallelizable]
      public void Test1()
      {
          var driver = CreateDriver();
          driver.Navigate().GoToUrl("http://www.mozilla.org");
          driver.FindElementByCssSelector("a[href='/projects/']").Click();
          Thread.Sleep(TimeSpan.FromSeconds(5));
          driver.Quit();
      }
  
      [Test]
      [Parallelizable]
      public void Test3()
      {
          var driver = CreateDriver();
          driver.Navigate().GoToUrl("http://www.mozilla.org");
          driver.FindElementByCssSelector("a[href='/contribute/']").Click();
          Thread.Sleep(TimeSpan.FromSeconds(5));
          driver.Quit();
      }
  
      **private FirefoxDriver CreateDriver()
      {
          lock(padlock)
          {
              return new FirefoxDriver();
          }
      }**
  }
  </code></pre>