测试完成后,Chromedriver不会删除临时文件夹中的scoped *目录 [英] Chromedriver not deleting scoped* dir in temp folder after test is complete
问题描述
由于最新的chromedriver.exe磁盘空间不足,因为chromedriver不会在执行结束时删除名为scoped_ *的文件夹.它占用了将近20 GB的空间用于400个测试.我尝试使用chromedriver的2.28和2.29版本.我也使用driver.close()和driver.Quit()正确退出了驱动程序. Chrome浏览器版本为57.
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.
推荐答案
我通过在退出驱动程序后添加删除以"scoped_dir"开头的临时文件夹的方式来解决此问题:
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 + ".");
}
}
}
希望有帮助!
这篇关于测试完成后,Chromedriver不会删除临时文件夹中的scoped *目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!