WeDriver FirefoxDriver cannot be used after calling quit ()

I'm having trouble getting the correct driver instance. my next setting

public class SeleniumBase{
    public static WebDriver  driver;
      public static void setUp(url,browser,port){
        driver = new FirefoxDriver();
      }
      public static void tearDown(){      
        driver.manage().deleteAllCookies();
        driver.close();
        driver.quit();         
      }
    }

public class BuildTest extends SeleniumBase{

    @BeforeClass
        public static void seleniumSetup(){
        try{
            // read properties
            url = prop.getProp("baseUrl");
            browser = prop.getProp("browser");
            port = prop.getProp("port");
            }
            SeleniumBase.setUp(url,browser,port);
            waitForLoginPage();
            App.login();
        }
    @AfterClass
        public static void seleniumTearDown(){
            App.logOut();
            SeleniumBase.tearDown();
        }
}

@RunWith(Suite.class)
    @Suite.SuiteClasses(
            {                                               
                Test1.class,
                Test2.class
            })

public class SmokeSuite {


}

now everything works fine for Test1.class, but when Test2.class is called from the package, a new driver instance is created using the setUp method, but App.Login () throws an error saying "The FirefoxDriver cannot be used after quit() was called"

Is there something wrong in my setup / break ..?

+4
source share
2 answers

, setUp() tearDown(), WebDriver: static. , driver.quit(), . .

JUnit @Before @After, @BeforeClass @AfterClass. , Test2, .

WebDriver, setUp() tearDown @Before @After . .

+1

driver.quit();, . driver null, void WebDriver null.

? , driver = new FirefoxDriver();, "" WebDriver, , null .

null quit .

public void tearDown() {
    driver.quit();
    driver = null;
}
0

All Articles