title: Selenium WebDriver All Parallel Tests Execute In A Single Window - TestNG - Java
body: <p>I am new to parallel execution and am trying to figure out why all 3 of my tests are trying to execute in a single window at the same time even though 3 separate windows are opened.</p>
  
  <p>I have 3 nodes running all with Chrome and maxInstance and maxSession set to 1, so each node should get receive 1 class to run, which it appears they do as you can see in this screenshot:
  <a href="https://i.stack.imgur.com/tKjBk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tKjBk.png" alt="enter image description here"></a></p>
  
  <p>This is what my test.xml file looks like:</p>
  
  <pre><code>&lt;suite name="Round Trip Suite" parllel="tests" thread-count="3"&gt;
  
   &lt;test name="Round Trip Matrix" preserve-order="true" parallel="classes" thread-count="3"&gt;
  
   &lt;classes&gt;
    &lt;class name ="roundTripMatrix.VerifyNewOrder"/&gt;
    &lt;class name ="roundTripMatrix.DeclineAndAccept"/&gt;
    &lt;class name ="roundTripMatrix.OrderOwnership"/&gt;
   &lt;/classes&gt;
  
   &lt;/test&gt;
  
  &lt;/suite&gt;
  </code></pre>
  
  <p>I am initializing the RemoteWebDriver in the @BeforeClass annotation like this:</p>
  
  <pre><code>if (browser.equals("Chrome"))
  {
      String chromeDriver = "";
      if (os.equals("Windows"))
      {
          chromeDriver = userDir.replace(project, "drivers\\chromedriver.exe");
      }
      else
      {
          chromeDriver = userDir.replace(project, "drivers/chromedriver");
      }
      System.setProperty("webdriver.chrome.driver", chromeDriver);
  
      if (useSeleniumGrid.equals("true"))
      {
          // Access Grid
          DesiredCapabilities capability = DesiredCapabilities.chrome();
          capability.setBrowserName("chrome");
          driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
      }
      else
      {
          driver = new ChromeDriver();
      }
  
  } // end if for Chrome browser
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have figured out the reason only one window was receiving the commands is because I wasn't using a threadlocal driver. My problem now is it fails at weird spots in all the windows, even though they were working while running individually previously.</p>