selenium 使用close和quit关闭driver的不同点

来源:互联网 发布:珠海seo推广 编辑:程序博客网 时间:2024/06/03 20:01
本地电脑运行了一段时间的selenium自动化脚本后,发现c盘空间明显减少,查找了下后发现临时文件中有将近10g的内容,而且有很多命令相似的文件夹,类似于“anonymous3435237790768500775webdriver-profile”。搜索后发现,这是由于关闭driver时使用了driver.close,close方法关闭后并不会清除临时文件中的webdriver临时文件,应该用driver.quit。quit关闭浏览器后,会自动删除临时文件夹。

Driver.Quit()与Driver.Close()的不同:

Driver.Quit():   Quit this dirver, closing every associated windows;
Driver.Close():   Close the current window, quiting the browser if it is the last window currently open.