Veerapathiran
Veerapathiran

Reputation: 1

SessionNotCreatedException - selenium webdriver

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

Upvotes: 0

Views: 163

Answers (1)

Bill Hileman
Bill Hileman

Reputation: 2838

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.

Upvotes: 1

Related Questions