title: Test cases getting skipped with Selenium WebDriver using TestNG framework
body: <p>I am using Selenium <code>WebDriver</code> with <code>TestNG</code> framework for running test suite on <strong>Windows and MAC</strong> platform on <strong>different browsers - Chrome, IE, firefox and Safari</strong>. I have around <strong>300 test cases</strong> in my test suite. </p>
  
  <p>The problem is that some of the test cases gets skipped in between where I believe driver becomes unresponsive. However the logs failed to capture any details why the test cases are getting skipped.</p>
  
  <p>The <code>reporter class</code> extends <code>TestListenerAdapter</code> and hence the skipped test cases gets listed in the log file with the use of <code>onConfigurationSkip</code> method. It only prints that a particular test case has been skipped.</p>
  
  <p>Below are some code snippets for reference</p>
  
  <h2>Code from Reporter Class</h2>
  
  <pre><code>@Override
  public void onConfigurationSkip(ITestResult testResult) {
      LOGGER.info(String.format("Skipped Configuration for : %s", testResult.getMethod().getMethodName()));
  }
  </code></pre>
  
  <h2>Sample Test Class</h2>
  
  <pre><code>public class TestClass {
  private WebDriver driver;
  
  @Parameters({ "platform", "browser"})
  @BeforeClass
  public void setUp(String platform, String browser) {
      // Creates a new driver instance based on platform and browser details
      driver = WebDriverFactory.getDriver(platform, browser);
      // Login to web application
      Utils.login(driver, username, password);
  }
  
  
  @Test
  public void sampleTestMethod() {
     // scripts for validating Web elements
  }
  
  @AfterClass
  public void tearDown() {
       driver.quit();;
  }
  }
  </code></pre>
  
  <p>Observations:</p>
  
  <ul>
  <li><p><code>driver.quit()</code> doesn't guarantee that driver instance has been closed because I can still see driver instance running in task manager. Again this is intermittent and happens sometimes only.</p></li>
  <li><p>This issue is observed on all platform and browser</p></li>
  <li><p>This is an intermittent issue and probability of its occurrence increases as the number of test cases increase in test suite</p></li>
  <li><p>There is no definite pattern of skipped test cases. The test cases get randomly skipped on some browser and platform</p></li>
  <li><p>The probability of occurance of skip test cases increases with subsequent run of test suite. I believe the reason is that more and more driver instances that were not properly closed keep running in the back ground</p></li>
  <li><p>Normally a <strong>test Class has 5-15 test methods</strong> and new <code>driver</code> instance is created every time in <code>@BeforeClass</code> method and is closed in <code>@AfterClass</code></p></li>
  </ul>
  
  <p>Any Suggestions? Thanks in Advance</p>