问题描述
最新的 chromedriver.exe 遇到磁盘空间不足的问题,因为 chromedriver 在执行结束时没有删除名为 scoped_* 的文件夹.它为 400 次测试占用了近 20 GB 的空间.我尝试使用 2.28 和 2.29 版本的 chromedriver.我也使用 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:
" +
"Exception: " + ex.Message + ".");
}
}
}
希望对你有帮助!
这篇关于测试完成后,Chromedriver 未删除临时文件夹中的作用域 * 目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!