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 face webdriver object driver Session ID is null error and also Script execution stops on error itself.If you’re reading this posts means you people are finding solution to fix this error.

Session ID is null using webdriver after calling quit

Basically this type of error will not comes many times,if we did any mistake in our test scripts because of copy pasting the same code in another class .Below is the error description it is saying your webdriver session id is null after calling driver.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-45154Kstep R', 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?

Whenever script is trying to find an Element after driver.quit or driver.close action in selenium scripts or after closing or quitting the driver session (i.e Open browser is closed),at that time there is no more session to find the elements ,so that time script throws session id is null exception on console.

ALSO READ  Selenium WebDriver Automation Test Life Cycle

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 Get HTML Source of WebElement in Selenium WebDriver using Python

As i have said exception will occurs once existing driver session is closed ,the same thing happen in above example script.If you have noticed in above example script,i’m closing the browser before “String pageTitle=driver.getTitle();” action,so at that line script will throw an exception,SO please review your code before starting test execution.

ALSO READ  Launch Firefox browser using Geckodriver - Selenium 3.0

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

 

exception in thread main org openqa selenium nosuchsessionexception session id is null
org.openqa.selenium.nosuchsessionexception: invalid session id
exception in thread “main” org.openqa.selenium.nosuchsessionexception: invalid session id
invalid session id selenium
no active session with id null
org.openqa.selenium.nosuchsessionexception: no such session
appium session id is null
org openqa selenium nosuchsessionexception invalid session id in jenkins

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 *