Chromedriver quit() method doesn't close all chrome.exe processes



  • When I am trying to close the chrome browser using driver.quit() and driver.close(), browser is getting closed but chromedriver.exe process is not getting closed. How can we remove these processes while we are closing the browser. I am trying in java.



  • Yeah, it can be a general issue as browsers (especially Chrome) don't always like closing their driver processes.

    You can put the below in the onFinish all tests method which kills them:

    String systemType = System.getProperty("os.name").toLowerCase();
    
            if (systemType.contains("win")) {
                try {
                    // Selenium drivers don't always close properly, kill them
                    System.out.println("Close one or more driver exe files");
                    Runtime.getRuntime().exec("taskkill /f /im chromedriver.exe");
                    Runtime.getRuntime().exec("taskkill /f /im operadriver.exe");
                    Runtime.getRuntime().exec("taskkill /f /im geckodriver.exe");
                    Runtime.getRuntime().exec("taskkill /f /im IEDriverServer.exe");
                } catch (IOException e) {
                    System.out.println("Failed to close one or more driver exe files");
                }
            }
    ```


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2