title: How to close all drivers in case of parallel run using testng selenium with java
body: <p>I am new to <em>Selenium(Java)</em> and using <em>TestNG</em> framework.I am using factory with data provider in the code.But in case of parallel execution , not able to close all the drivers.Find below my test code.Please advise.</p>
  
  <pre><code>public class FactoryDataProvider {
  
      private String param;
      WebDriver driver =null;
  
      @Factory(dataProvider = "dataMethod")
      public FactoryDataProvider(String param) {
          this.param = param;
  
  
      }
  
      @DataProvider(parallel = true)
      public static Object[][] dataMethod() {
          return  new Object[][] {
                  new Object[] { "http://www.yahoo.com" }, 
                 new Object[] { "http://www.google.com" } } ;
      }
  
  
      @BeforeClass
      public void beforeTest(){
          System.out.println("Before Test executed : ");
          driver = new FirefoxDriver();
      }
  
  
    @Test
      public void testMethodOne() {
          System.out.println("Thread ID :"+Thread.currentThread().getId());
          System.out.println("Test method one output: " + param);
          driver.get(param);
      }
  
      @Test
      public void testMethodTwo() {
          System.out.println("Thread ID :"+Thread.currentThread().getId());
          System.out.println("Test method two output: " + param);
          driver.get(param);
      }
  
  
      @AfterTest
      public void tearDown() {
  
          driver.quit();
      }
  }
  </code></pre>