Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session ID is null. Using WebDriver after calling quit()?

I am trying to add new contact by reading test data from and excel file. The firt row data is created sucessfully. After that for second row I recieve error as "org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?"

I have rechecked my code and other test cases are found to be working fine. I follow the following flow Go to Base url->Login->Add contacts->driver.quit()

@AfterMethod
    public void teardown() {

        driver.quit();
    }

I am expecting that data shoul be read and multiple contacts should be added

like image 314
SuperShazam Avatar asked Dec 06 '25 18:12

SuperShazam


1 Answers

You are using @AfterMethod here and @AfterMethod gets executed after every execution of the method and in your case, after one iteration from the excel it gets executed and the driver instance gets ended because you have used driver.quit() here.

So to solve this problem, you should use @AfterTest instead of @AfterMethod as @AfterTest would run only when all the rows from the excel gets executed and your test case execution has been completed.

like image 187
Sameer Arora Avatar answered Dec 09 '25 13:12

Sameer Arora