Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromedriver not deleting scoped* dir in temp folder after test is complete

With latest chromedriver.exe running into out of disk space issues as chromedriver is not deleting the folder named scoped_* at the end of the execution. It is occupying almost 20 GB of space for 400 tests. I tried with both 2.28 and 2.29 versions of chromedriver. I am exiting the driver properly with driver.close() and driver.Quit() too. Chrome browser version is 57.

like image 937
Karthi Avatar asked Apr 08 '17 00:04

Karthi


People also ask

How do I remove Chromedriver exe?

First end the process of chromedriver.exe from Task Manger, then Delete the chromedriver.exe from your project bin file and check whether Selenium. WebDriver. ChromeDriver package installed or not, If it's not installed you should installSelenium.

How do I change Chromedriver path?

Go to the terminal and type the command: sudo nano /etc/paths. Enter the password. At the bottom of the file, add the path of your ChromeDriver. Type Y to save.

Where is Chromedriver saved?

Chromium/Google Chrome Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following Using a Chrome executable in a non-standard location .

How do I remove Chromedriver exe from Eclipse?

To do that, you need to click on Task Manager (Cntrl+Alt+Del) -> Select Task Manager and search for all Chorme Driver(s) and delete these tasks from process on Task Manager.

Why does chromedriver keep deleting my temp files?

This appears to be a race condition between ChromeDriver and Chrome. ChromeDriver creates these temp directories for use by Chrome, and at the end ChromeDriver tries to delete those directories.

Why can't chromedriver delete certain directories?

ChromeDriver waits for the main Chrome process to terminate before doing the deletion, but some Chrome child processes might still be running and holding on to those directories, causing the deletion to fail. Currently ChromeDriver doesn't retry the deletion. Adding some retries might be the easiest fix.

What is the use of scoped_Dir* in chromedriver?

This scoped_dir* is required to pass the default/mandatory/configured arguments to initiate Chrome Browser. As an example: But on successfull invocation of driver.quit () i.e. clean exit this temporary folder should get deleted by the ChromeDriver.

How do I clear the scoped_Dir folder?

Incase you are still seeing scoped_dir* (incase of parallel tests) you can store the userDataDir from Returned Capabilities and delete that folder. This cleans up the scoped_dir folder for that specific instance and helps when running parallel tests.


1 Answers

I managed this by adding deletion of temp folders that begins with "scoped_dir" after quitting driver like:

 public static void teardown_()
        {
            // quit driver
            if (driver != null)
                driver.Quit();

            // delete all "scoped_dir" temp folders 
            string tempfolder = System.IO.Path.GetTempPath();
            string[] tempfiles = Directory.GetDirectories(tempfolder, "scoped_dir*", SearchOption.AllDirectories);
            foreach (string tempfile in tempfiles)
            {
                try
                {
                    System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(tempfolder);
                    foreach (System.IO.DirectoryInfo subDirectory in directory.GetDirectories()) subDirectory.Delete(true);
                }
                catch (Exception ex)
                {
                    writeEx("File '" + tempfile + "' could not be deleted:\r\n" +
                            "Exception: " + ex.Message + ".");
                }
            }
        } 

Hope it helps!

like image 90
Daniel Dumine Avatar answered Sep 29 '22 22:09

Daniel Dumine