title: Selenium Grid + TestNG + WebDriver: running tests in parallel doesn't work properly
body: <p>I have Selenium Grid2 with a hub and two nodes.</p>
  
  <p>Hub is operated by: </p>
  
  <pre><code>java -jar selenium-server-standalone-2.32.0.jar -role hub -port 4444
  </code></pre>
  
  <p>Nodes are operated by: </p>
  
  <pre><code>java -jar selenium-server-standalone-2.32.0.jar -role node -hub http://10.20.46.171:4444/wd/hub -port 5555
  </code></pre>
  
  <p>In hub console, I see both nodes up and running.</p>
  
  <p>My TestNB config (testng.xml):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&gt;
  &lt;suite name="Full suite" parallel="classes" thread-count="4"&gt;
    &lt;parameter name="hubAddress" value="http://127.0.0.1:4444/wd/hub"&gt;&lt;/parameter&gt;
    &lt;test verbose="2" name="Full"&gt;
      &lt;packages&gt;
        &lt;package name="com.example.tests"&gt;
        &lt;/package&gt;
      &lt;/packages&gt;
    &lt;/test&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p>In com/example/tests, I have a base class TestBase and 4 other classes that extend TestBase</p>
  
  <p>In TestBase.java, I have:</p>
  
  <pre><code>package com.example.tests;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.remote.RemoteWebDriver;
  import org.testng.annotations.AfterClass;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Parameters;
  
  public class TestBase {
  
    protected WebDriver driver;
  
    @BeforeClass
    @Parameters("hubAddress")
    public void startDriver(String hubAddress) throws MalformedURLException {
      driver = new RemoteWebDriver(new URL(hubAddress), DesiredCapabilities.Firefox());
    }
  
    @AfterClass
    public void stopDriver() {
      driver.quit();
      driver = null;
    }
  
  }
  </code></pre>
  
  <p>In Test1.java, I have:</p>
  
  <pre><code>package com.example.tests;
  import org.testng.annotations.Test;
  
  @Test
  public class Test1 extends TestBase {
  
    public void test1() {
      driver.get("http://www.google.com/");
    }
  
  }
  </code></pre>
  
  <p>In Test2.java, I have:</p>
  
  <pre><code>package com.example.tests;
  import org.testng.annotations.Test;
  
  @Test
  public class Test2 extends TestBase {
  
    public void test2() {
      driver.get("http://www.facebook.com/");
    }
  
  }
  </code></pre>
  
  <p>In Test3.java, I have:</p>
  
  <pre><code>package com.example.tests;
  import org.testng.annotations.Test;
  
  @Test
  public class Test3 extends TestBase {
  
    public void test3() {
      driver.get("http://www.yahoo.com/");
    }
  
  }
  </code></pre>
  
  <p>In Test4.java, I have:</p>
  
  <pre><code>package com.example.tests;
  import org.testng.annotations.Test;
  
  @Test
  public class Test4 extends TestBase {
  
    public void test4() {
      driver.get("http://www.cnn.com/");
    }
  
  }
  </code></pre>
  
  <p>I run all this with Ant. Here is a piece of code:</p>
  
  <pre><code>   &lt;target name="run-tests" depends="build"&gt;
          &lt;testng classpathref="LoadTests.classpath"&gt;
              &lt;xmlfileset dir="." includes="testng.xml"/&gt;
          &lt;/testng&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p>The command line: </p>
  
  <pre><code>ant run-tests
  </code></pre>
  
  <p><strong>How it works now:</strong> Test1 runs on Node1 and Test2 runs on Node2 (simultaneously). AFTER THAT, Test3 runs on Node1 and Test4 runs on Node2 (simultaneously).</p>
  
  <p><strong>Desired behavior:</strong> All four tests run simultaneously in one shot: two on one node (say, Test1, Test3) and other two on the second node (Test2, Test4).</p>
  
  <p><strong>Question:</strong> What should I change so that it works as desired?</p>