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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With