Session ID is null using webdriver after calling quit

Session ID is null using webdriver after calling quit,While running selenium webdriver scripts in Eclipse tool some times we will face Session ID is null error ,Script execution stops.

Session ID is null using webdriver after calling quit

Below is the error description,where it is saying your webdriver session id is null after calling quit method in webdriver,why this exception comes?

org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'KARYA-45154KR', ip: '192.168.159.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: SuiteDriver

Why Session ID Exception?

When you are trying to findElement after driver.quit or driver.close action in the selenium scripts,after closing or quitting the driver session,there is no more session to find the elements ,so that time script throws session id is null exception on console.

ALSO READ  How to take screenshot in Selenium IDE

CODE Example:

public class sampleTest{

public static WebDriver driver;

public void loginTest(){

System.setProperty("webdriver.driver.chrome","path of the chromedriver.exe file");
driver = new chromeDriver();

driver.get("http://www.google.co.in");
driver.findElement(By.id("")).sendKeys("www.easyselenium.com");
driver.click();

driver.quit();

String pageTitle=driver.getTitle();
System.out.println(pageTitle);

}

}

CODE OUTPUT:

org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: ‘3.5.3’, revision: ‘a88d25fe6b’, time: ‘2017-08-29T12:42:44.417Z’
System info: host: ‘XXXXXXXX’, ip:’XXXXXXXXXXXXXXX’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_91’
Driver info: driver.version: SuiteDriver

ALSO READ  How To write Test Case is PASS or FAIL using Selenium

ALSO READ:

Read Data From properties file using Selenium
Launch Firefox Browser using GeckoDriver
Selenium-Testng examples to execute multiple classes
Selenium WebDriver Methods
Generate HTML Reports using Selenium.
How to write Test Cases PASS or FAIL in Excel using Selenium

Rajesh

Rajesh has over 8+ years of experience in Quality Assurance (Automation/ Manual). I've completed his B.Texh. He is an experienced software tester,work experience include working on tools like TestNG, Sikuli, Autoit, Selenium Builder and Appium. Abhishek has worked on various projects from verticals like Retail, Health Insurance, tolling and many more and passionate about designing Automation Frameworks that are effective and easy to maintain using Selenium Java.

Leave a Reply

Your email address will not be published. Required fields are marked *