AMA: Why I am getting Session id is null?
Here is my video series on integrating Cross-Browser Support Framework in your Test Framework. If you haven’t watched it yet, definitely check that out, you will have something to learn.
org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()? The session ID is null is a frequent exception that we see while executing tests using WebDriver.
This can happen due to a few reasons. Here I am sharing the below reasons I have experienced.
Scenario 1
This can be due to the browser and the respective driver. you are using. Each driver has its own way of calling browser.close(). If you call driver.quit() multiple times with chrome driver, it will ignore.
Scenario 2
If you have declared your Webdriver as a static variable, this might cause problems, especially when you are running tests in parallel.
public static WebDriver driver = DriverFactory.getWebDriver();
//Which was causing the issue.