杀掉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();
    }
原文地址:https://www.cnblogs.com/yanzhe/p/7553370.html