殺掉chromedriver.exe進程,防止浪費資源


方法

    public void kill_chromedriver(){
        Runtime runtime=Runtime.getRuntime();
        try{
            System.out.println("kill chromedriver.exe");
            runtime.exec("taskkill /f /im chromedriver.exe");
        }catch(Exception e){
            System.out.println("Error!");
        }
    }

使用例子

 
         
    Common_method common_method = new Common_method();
@After
public void tearDown() throws Exception {
 try { Thread.sleep(1000); } catch (Exception e) { // TODO: handle exception
 } driver.quit();  common_method.kill_chromedriver(); }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM