Shutting down Selenium without closing the browser, while cleaning up temporary files Shutting down Selenium without closing the browser, while cleaning up temporary files selenium selenium

Shutting down Selenium without closing the browser, while cleaning up temporary files


After your code is done, kill the executable process and then exit the program without driver.quit()

    try{    /*kill the process*/        Runtime.getRuntime().exec("taskkill /im chromedriver.exe /f");        Thread.sleep(10000);    }catch(Exception e){        e.printStackTrace();    }    /*Exit*/    System.exit(0)


You could just quit the program while leaving the browser intact. Assuming you have a console application:

WebDriver driver = new FirefoxDriver();driver.get("http://www.google.com");System.exit(0);