Receiving error “org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after...












1















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.



Base Class:



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<String> result = new ArrayList<String>();

for (File file : files) {
if (file.isFile()) {
result.add(file.getAbsolutePath());
}
}

Object resultarray = new Object[result.size()][1];
for (int i=0; i<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);

}


Child Class:



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();
}

}


First failed method from console:



[RemoteTestNG] detected TestNG version 6.10.0
[TestNG] Running:
C:AppDataLocalTemptestng-eclipse--1577707927testng-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-workspaceAutomationconfigQAAddressableTargetAddressableTarget.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)


Look inside my POM:



<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">
<modelVersion>4.0.0</modelVersion>
<groupId>AdVantics</groupId>
<artifactId>AdVanticsQAAutomation</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.11.0</version>
</dependency>

<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
<!-- <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile> -->
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>

</project>









share|improve this question





























    1















    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.



    Base Class:



    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<String> result = new ArrayList<String>();

    for (File file : files) {
    if (file.isFile()) {
    result.add(file.getAbsolutePath());
    }
    }

    Object resultarray = new Object[result.size()][1];
    for (int i=0; i<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);

    }


    Child Class:



    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();
    }

    }


    First failed method from console:



    [RemoteTestNG] detected TestNG version 6.10.0
    [TestNG] Running:
    C:AppDataLocalTemptestng-eclipse--1577707927testng-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-workspaceAutomationconfigQAAddressableTargetAddressableTarget.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)


    Look inside my POM:



    <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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>AdVantics</groupId>
    <artifactId>AdVanticsQAAutomation</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
    <!-- Selenium -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.11.0</version>
    </dependency>
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.52.0</version>
    </dependency>
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.11.0</version>
    </dependency>

    <!-- TestNG -->
    <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.10</version>
    </dependency>
    </dependencies>

    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.6.1</version>
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    </configuration>
    </plugin>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M1</version>
    <configuration>
    <suiteXmlFiles>
    <suiteXmlFile>testng.xml</suiteXmlFile>
    <!-- <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile> -->
    </suiteXmlFiles>
    </configuration>
    </plugin>
    </plugins>
    </build>

    </project>









    share|improve this question



























      1












      1








      1


      0






      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.



      Base Class:



      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<String> result = new ArrayList<String>();

      for (File file : files) {
      if (file.isFile()) {
      result.add(file.getAbsolutePath());
      }
      }

      Object resultarray = new Object[result.size()][1];
      for (int i=0; i<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);

      }


      Child Class:



      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();
      }

      }


      First failed method from console:



      [RemoteTestNG] detected TestNG version 6.10.0
      [TestNG] Running:
      C:AppDataLocalTemptestng-eclipse--1577707927testng-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-workspaceAutomationconfigQAAddressableTargetAddressableTarget.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)


      Look inside my POM:



      <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">
      <modelVersion>4.0.0</modelVersion>
      <groupId>AdVantics</groupId>
      <artifactId>AdVanticsQAAutomation</artifactId>
      <version>0.0.1-SNAPSHOT</version>

      <dependencies>
      <!-- Selenium -->
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.11.0</version>
      </dependency>
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-htmlunit-driver</artifactId>
      <version>2.52.0</version>
      </dependency>
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-server</artifactId>
      <version>3.11.0</version>
      </dependency>

      <!-- TestNG -->
      <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.10</version>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.6.1</version>
      <configuration>
      <source>1.8</source>
      <target>1.8</target>
      </configuration>
      </plugin>

      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>3.0.0-M1</version>
      <configuration>
      <suiteXmlFiles>
      <suiteXmlFile>testng.xml</suiteXmlFile>
      <!-- <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile> -->
      </suiteXmlFiles>
      </configuration>
      </plugin>
      </plugins>
      </build>

      </project>









      share|improve this question
















      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.



      Base Class:



      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<String> result = new ArrayList<String>();

      for (File file : files) {
      if (file.isFile()) {
      result.add(file.getAbsolutePath());
      }
      }

      Object resultarray = new Object[result.size()][1];
      for (int i=0; i<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);

      }


      Child Class:



      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();
      }

      }


      First failed method from console:



      [RemoteTestNG] detected TestNG version 6.10.0
      [TestNG] Running:
      C:AppDataLocalTemptestng-eclipse--1577707927testng-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-workspaceAutomationconfigQAAddressableTargetAddressableTarget.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)


      Look inside my POM:



      <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">
      <modelVersion>4.0.0</modelVersion>
      <groupId>AdVantics</groupId>
      <artifactId>AdVanticsQAAutomation</artifactId>
      <version>0.0.1-SNAPSHOT</version>

      <dependencies>
      <!-- Selenium -->
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.11.0</version>
      </dependency>
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-htmlunit-driver</artifactId>
      <version>2.52.0</version>
      </dependency>
      <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-server</artifactId>
      <version>3.11.0</version>
      </dependency>

      <!-- TestNG -->
      <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.10</version>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.6.1</version>
      <configuration>
      <source>1.8</source>
      <target>1.8</target>
      </configuration>
      </plugin>

      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>3.0.0-M1</version>
      <configuration>
      <suiteXmlFiles>
      <suiteXmlFile>testng.xml</suiteXmlFile>
      <!-- <suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile> -->
      </suiteXmlFiles>
      </configuration>
      </plugin>
      </plugins>
      </build>

      </project>






      java eclipse maven selenium testng






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 8:14









      halfer

      14.5k758111




      14.5k758111










      asked Nov 14 '18 at 4:53









      DanDan

      61




      61
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You can not user driver after calling the quit method.
          Just remove @Test annotation from all of the methods and just keep it for runTest method and it will solve your problem.






          share|improve this answer
























          • Thank you. I'll try that out. Can you explain why that happens?

            – Dan
            Nov 14 '18 at 6:08











          • You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

            – Ronak
            Nov 14 '18 at 9:48











          • Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

            – Dan
            Nov 14 '18 at 12:39











          • No need to do this as others are normal java methods.

            – Ronak
            Nov 14 '18 at 13:17











          • calling quit() destroys the instance of webdriver

            – Corey Goldberg
            Nov 14 '18 at 19:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293377%2freceiving-error-org-openqa-selenium-nosuchsessionexception-session-id-is-null%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can not user driver after calling the quit method.
          Just remove @Test annotation from all of the methods and just keep it for runTest method and it will solve your problem.






          share|improve this answer
























          • Thank you. I'll try that out. Can you explain why that happens?

            – Dan
            Nov 14 '18 at 6:08











          • You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

            – Ronak
            Nov 14 '18 at 9:48











          • Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

            – Dan
            Nov 14 '18 at 12:39











          • No need to do this as others are normal java methods.

            – Ronak
            Nov 14 '18 at 13:17











          • calling quit() destroys the instance of webdriver

            – Corey Goldberg
            Nov 14 '18 at 19:45
















          1














          You can not user driver after calling the quit method.
          Just remove @Test annotation from all of the methods and just keep it for runTest method and it will solve your problem.






          share|improve this answer
























          • Thank you. I'll try that out. Can you explain why that happens?

            – Dan
            Nov 14 '18 at 6:08











          • You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

            – Ronak
            Nov 14 '18 at 9:48











          • Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

            – Dan
            Nov 14 '18 at 12:39











          • No need to do this as others are normal java methods.

            – Ronak
            Nov 14 '18 at 13:17











          • calling quit() destroys the instance of webdriver

            – Corey Goldberg
            Nov 14 '18 at 19:45














          1












          1








          1







          You can not user driver after calling the quit method.
          Just remove @Test annotation from all of the methods and just keep it for runTest method and it will solve your problem.






          share|improve this answer













          You can not user driver after calling the quit method.
          Just remove @Test annotation from all of the methods and just keep it for runTest method and it will solve your problem.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 5:12









          RonakRonak

          1,43311833




          1,43311833













          • Thank you. I'll try that out. Can you explain why that happens?

            – Dan
            Nov 14 '18 at 6:08











          • You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

            – Ronak
            Nov 14 '18 at 9:48











          • Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

            – Dan
            Nov 14 '18 at 12:39











          • No need to do this as others are normal java methods.

            – Ronak
            Nov 14 '18 at 13:17











          • calling quit() destroys the instance of webdriver

            – Corey Goldberg
            Nov 14 '18 at 19:45



















          • Thank you. I'll try that out. Can you explain why that happens?

            – Dan
            Nov 14 '18 at 6:08











          • You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

            – Ronak
            Nov 14 '18 at 9:48











          • Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

            – Dan
            Nov 14 '18 at 12:39











          • No need to do this as others are normal java methods.

            – Ronak
            Nov 14 '18 at 13:17











          • calling quit() destroys the instance of webdriver

            – Corey Goldberg
            Nov 14 '18 at 19:45

















          Thank you. I'll try that out. Can you explain why that happens?

          – Dan
          Nov 14 '18 at 6:08





          Thank you. I'll try that out. Can you explain why that happens?

          – Dan
          Nov 14 '18 at 6:08













          You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

          – Ronak
          Nov 14 '18 at 9:48





          You are already calling all the other methods from runTest method. then whats the need of defining other method as @Test.

          – Ronak
          Nov 14 '18 at 9:48













          Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

          – Dan
          Nov 14 '18 at 12:39





          Okay. One last question. How can I modify this to allow pass or fail loggin in testng for each method?

          – Dan
          Nov 14 '18 at 12:39













          No need to do this as others are normal java methods.

          – Ronak
          Nov 14 '18 at 13:17





          No need to do this as others are normal java methods.

          – Ronak
          Nov 14 '18 at 13:17













          calling quit() destroys the instance of webdriver

          – Corey Goldberg
          Nov 14 '18 at 19:45





          calling quit() destroys the instance of webdriver

          – Corey Goldberg
          Nov 14 '18 at 19:45


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293377%2freceiving-error-org-openqa-selenium-nosuchsessionexception-session-id-is-null%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine