0

I have a test case in which there are 3 methods

 Class
 {
   Method1();
   Method2();
   Method3()
 }

Now, I want to run Method1() in IE, Method2() in FF and Method3() in Chrome. I have written the code and it works pretty fine. Only problem is that it gives an error in Console "org.openqa.selenium.remote.SessionNotFoundException: Session ID is null. Using WebDriver after calling quit()?"

After Method1() gets completed, I quit driver like

 driver.quit();
 driver=null;
 driver = new FirefoxDriver();

Similarly for Chrome also after Method2() gets completed.

Can someone please guide me why I am getting this message and what's the solution ?

I don't want to use Selenium grid. Thanks

2
  • If the suggestion by @lost below did not work, you need to post way more that just "not working". See this: stackoverflow.com/help/mcve Commented Jun 16, 2014 at 17:00
  • Not working here means getting the same error "org.openqa.selenium.remote.SessionNotFoundException: Session ID is null. Using WebDriver after calling quit()?" Commented Jun 18, 2014 at 3:09

1 Answer 1

0

According to your explanation this is what I understood :-

  1. Method1() is for IE
  2. Method2() is for FF
  3. Method3() is for chrome

Why are you ending the code with new WebDriver instantiation? Instead it makes more sense when you create a a structure like below.

Class {
    WebDriver driver;
    Method1() {
        driver = new InternetExplorerDriver();
        //code for IE goes here
        driver.quit();
    }

    Method2() {
        driver = new FirefoxDriver();
        //code for FF goes here
        driver.quit();
    }

    Method3() {
        driver = new ChromeDriver();
        //code for chrome goes here
        driver.quit();
    }    
}

Your requirement seems out of ordinary. If you want to test some code in different browsers, its better to use a framework such as TestNG/JUnit or specify different test for different browsers.

Hope this helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for posting comment but I tried with your way as well but it's not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.