title: Receiving error "org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?"
body: <p>I am running into an issue where my test performs the actions in the browser per method, but is displaying as failed in TestNG with the error mentioned in the title. Please look over and help correct this issue. I'm still fairly new to automation and had no luck at sorting this out.</p>
  
  <p>Base Class:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.nio.file.Files;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Calendar;
  import java.util.Enumeration;
  import java.util.List;
  import java.util.Properties;
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.JavascriptExecutor;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.ie.InternetExplorerDriver;
  import org.openqa.selenium.support.ui.Select;
  import org.testng.Assert;
  import org.testng.annotations.Test;
  
  public class TestListBase {
      String chromeDriverPath = "src/main/resources/chromedriver.exe";
      String ieDriverPath = "src/main/resources/IEDriverServer.exe";
      WebDriver driver;
      Properties testData;
      static String testSuitName;
      static String baseFolder = "config\\";
  
      public static Object[][] findPropertyFiles(String testName) {       
          // First read test suite name.
          Properties p = readProperties(baseFolder + "TestSuitToRun.txt");
          testSuitName = p.getProperty("TestSuitName");
  
          // Read test properties     
          File[] files = new File("config\\" + testSuitName + "\\" + testName + "\\").listFiles();
          List&lt;String&gt; result = new ArrayList&lt;String&gt;();
  
          for (File file : files) {
              if (file.isFile()) {
                  result.add(file.getAbsolutePath());
              }
          }
  
          Object[][] resultarray = new Object[result.size()][1];
          for (int i=0; i&lt;result.size(); i++) {
              resultarray[i][0] = result.get(i);
          }
          return resultarray;
      }
  
      private static Properties readProperties(String path) {
          Properties properties = new Properties();
          InputStream input = null;
          try {
              input = new FileInputStream(path);
              properties.load(input);
          }
          catch (Exception ex) {
  
          }
          finally {
              if (input != null) {
                  try {
                      input.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }           
          }
          return properties;
      }
  
      protected void readTestData(String testDataPath) {
          // Read base properties
          Properties baseProperties = readProperties(baseFolder + testSuitName + "\\baseProperties.txt");
          testData = readProperties(testDataPath);
          testData.putAll(baseProperties);        
      }
  
      protected void waitForBrowser() {
          waitForBrowser(1);
      }
  
      protected void waitForBrowser(int timeoutSec) {
          try {
              Thread.sleep(timeoutSec * 1000);
          } catch (InterruptedException e) {
              System.out.println("got interrupted!");
  
          }
      }
  
      protected void setDriver(WebDriver driverparam) {
          this.driver = driverparam;
      }
  
      protected WebDriver getDriver() {
          return this.driver;
      }
  
  
      protected void intializeDriver() {
          String browserType = testData.getProperty("browser");
          if (browserType.equalsIgnoreCase("chrome")) {
              System.setProperty("webdriver.chrome.driver", chromeDriverPath);
              driver = new ChromeDriver();        
  
          }
          else if (browserType.equalsIgnoreCase("ie")) {
              System.setProperty("webdriver.ie.driver", ieDriverPath);
              driver = new InternetExplorerDriver();
          }
          else if (browserType.equalsIgnoreCase("firefox")) {
              driver = new FirefoxDriver();           
          }
          else {
              System.out.println("Unknown Browser Type:" + browserType);
              return;
          }
  
          driver.manage().deleteAllCookies();
          driver.manage().window().maximize();
          driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
          driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
  
      }
  </code></pre>
  
  <p>Child Class:</p>
  
  <pre><code>import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.List;
  import java.util.Properties;
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.JavascriptExecutor;
  import org.openqa.selenium.Keys;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.ie.InternetExplorerDriver;
  import org.openqa.selenium.support.ui.Select;
  import org.testng.Assert;
  import org.testng.annotations.AfterSuite;
  import org.testng.annotations.BeforeSuite;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
  
  public class AddressableTarget extends TestListBase {
      @DataProvider(name = "PropertyFile")     
      public static Object[][] getPropertyFiles() { 
              return findPropertyFiles("AddressableTarget");
      }
  
      @Test(priority = 0, dataProvider = "PropertyFile")
      public void runTest(String filename) {
          readTestData(filename);
          intializeDriver();
  
          openBrowser();
          login();
          gotoAddressableTarget();
          terminateBrowser();
  
      }
  
      @Test(priority = 1)
      void openBrowser() {
          driver.get(testData.getProperty("baseUrl"));
  
  
      }
  
      @Test(priority = 2)
      public void login() {
          driver.findElement(By.xpath("//input[@name='logonIDmanual']"))
                  .sendKeys(testData.getProperty("user"));
          driver.findElement(By.xpath("//input[@type='password']"))
                  .sendKeys(testData.getProperty("password"));
          driver.findElement(By.xpath("//input[@type='submit']"))
                  .click();
          waitForBrowser();
      }
  
      @Test(priority = 3)
      public void gotoAddressableTarget() {
          driver.findElement(By.xpath("//span[contains(text(), 'Addressable Target')]")).click();
          waitForBrowser();
      }
  
      @Test(priority = 4)
      public void terminateBrowser() {
          driver.quit();
      }
  
  }
  </code></pre>
  
  <p>First failed method from console:</p>
  
  <pre><code>[RemoteTestNG] detected TestNG version 6.10.0
  [TestNG] Running:
    C:\AppData\Local\Temp\testng-eclipse--1577707927\testng-customsuite.xml
  
  Starting ChromeDriver 2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a) on port 20262
  Only local connections are allowed.
  Nov 13, 2018 10:56:22 PM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: OSS
  PASSED: runTest("C:\eclipse-workspace\Automation\config\QA\AddressableTarget\AddressableTarget.txt")
  PASSED: terminateBrowser
  FAILED: openBrowser
  org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
  Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
  System info: host: 'USLJTMWF72', ip: '10.5.152.19', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_181'
  Driver info: driver.version: RemoteWebDriver
      at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:125)
      at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
      at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:273)
      at com.AddressableTarget.openBrowser(AddressableTarget.java:47)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
      at org.testng.TestRunner.privateRun(TestRunner.java:756)
      at org.testng.TestRunner.run(TestRunner.java:610)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
      at org.testng.SuiteRunner.run(SuiteRunner.java:289)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
      at org.testng.TestNG.runSuites(TestNG.java:1133)
      at org.testng.TestNG.run(TestNG.java:1104)
      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
  </code></pre>
  
  <p>Look inside my POM:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;AdVantics&lt;/groupId&gt;
    &lt;artifactId&gt;AdVanticsQAAutomation&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
    &lt;dependencies&gt;
    &lt;!-- Selenium --&gt;
    &lt;dependency&gt;
       &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
       &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
       &lt;version&gt;3.11.0&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
      &lt;artifactId&gt;selenium-htmlunit-driver&lt;/artifactId&gt;
      &lt;version&gt;2.52.0&lt;/version&gt;
  &lt;/dependency&gt;    
    &lt;dependency&gt;
       &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
       &lt;artifactId&gt;selenium-server&lt;/artifactId&gt;
       &lt;version&gt;3.11.0&lt;/version&gt;
    &lt;/dependency&gt; 
  
    &lt;!-- TestNG --&gt;
    &lt;dependency&gt;
       &lt;groupId&gt;org.testng&lt;/groupId&gt;
       &lt;artifactId&gt;testng&lt;/artifactId&gt;
       &lt;version&gt;6.10&lt;/version&gt;
    &lt;/dependency&gt; 
  &lt;/dependencies&gt;
  
    &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.6.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.0.0-M1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;suiteXmlFiles&gt;
                      &lt;suiteXmlFile&gt;testng.xml&lt;/suiteXmlFile&gt;
                      &lt;!-- &lt;suiteXmlFile&gt;src/main/resources/testng.xml&lt;/suiteXmlFile&gt; --&gt;
                  &lt;/suiteXmlFiles&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;  
    &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>