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

后端 未结 6 1592
野性不改
野性不改 2021-02-07 09:26

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

6条回答
  •  鱼传尺愫
    2021-02-07 09:49

    We are running multiple ChromeDrivers at high concurrency, and I have got a big improvement using Cornel's idea of using adding a driver.close() before the driver.quit() in a test. Maybe it gives Chrome a little more time to shut down its processes before the quit, preventing a race/lock condition from happening?

    If it turns out we need to do more, I will try coding a similar answer as Daniel has provided, but due to our level of concurrency, I'll attempt to delete the specific folders created by each driver instance.

    The directory name can be obtained this way:

    Capabilities caps = driver.getCapabilities();
    Map chromeReturnedCapsMap = (Map) caps.getCapability("chrome");
    LOG.debug("  Chrome Driver Temp Dir   : " + chromeReturnedCapsMap.get("userDataDir"));
    

    This will print something like
    Chrome Driver Temp Dir : C:\Users\Metal666\AppData\Local\Temp\scoped_dir35344_14668

    However, it appears two directories are created - they differ in name after be last underscore. So for example, the directories might be named:

    C:\Users\Metal666\AppData\Local\Temp\scoped_dir35344_14668 C:\Users\Metal666\AppData\Local\Temp\scoped_dir35344_28790

    so the code would need to cater for deleting both files.

    Tested using Selenium 3.141.59, Chrome 74.0.., ChromeDriver 74.0..

提交回复
热议问题