0

I have implement two scenario outlines in one feature file at cucumber, and also wrote script that new browser initiate in @After Junit command when my test case fail.

@After
public void teardownpatientregis(Scenario s) throws IOException, InterruptedException
{
    if(s.isFailed())
    {
        Screenshots.getscreenshot(s);
        driver.quit();
        initialize(failbrowser);
        url(failurl);
        Logintestpage.getusername(failuser);
        Logintestpage.getpassword(failpass);
        Logintestpage.loginalert();
        Thread.sleep(2000);
        Logintestpage.logout();
        driver.quit();
    }
}

But the new Webdriver does not initiate after close my browser. It shows SessionNotCreatedException errors. Please help me to resolve this issue

clemens
  • 16,716
  • 11
  • 50
  • 65
  • 1
    What have you attempted to help resolve the problem? – Jeffrey Jan 03 '18 at 06:01
  • Possible duplicate of [How can I reconnect to the browser opened by webdriver with selenium?](https://stackoverflow.com/questions/47861813/how-can-i-reconnect-to-the-browser-opened-by-webdriver-with-selenium/47862867#47862867) – undetected Selenium Jan 03 '18 at 06:07
  • Possible duplicate of: https://stackoverflow.com/questions/48231987/cucumber-jvs-selenium-grid-selenium-sessionnotcreatedexception-unable-to-cre – Marit Jan 13 '18 at 14:24

1 Answers1

1

The new Webdriver does not initiate after closing the browser because you are NOT closing the browser, you are issuing a quit instead.

Replace at least the first driver.quit() with driver.close()if not both of them.

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24