【问题标题】:Geckodriver is creating rust_mozprofile directories when I use Selenium Webdriver当我使用 Selenium Webdriver 时,Geckodriver 正在创建 rust_mozprofile 目录
【发布时间】:2018-09-18 00:43:04
【问题描述】:

我正在使用带有geckodriver 的 Selenium Python 绑定。在我的 Windows 7 Temp 目录中创建每个浏览器会话后rust_mozprofile 目录。数百个新创​​建的目录可以快速添加到 5 - 6 GB。

我正在寻找解决方案,但到目前为止我还没有找到任何解决方案。我可以手动删除这些目录,但这不是最佳选择。有没有办法在 Selenium 中以编程方式解决这个问题?

这不是重复的,原因如下:

我检查了答案here,但它并没有解决我的问题。我想找到一种方法来创建一个单独的 Firefox 配置文件并在 Selenium 测试执行中使用它,或者如果可能的话,在 Selenium 中以编程方式解决这个问题。

【问题讨论】:

标签: python selenium selenium-webdriver geckodriver


【解决方案1】:

一个解决方案是使用 driver.quit() 而不是 driver.close()

如解释here

另一种解决方案是添加自定义配置文件

fp = webdriver.FirefoxProfile('specify location to profile .default') driver = webdriver.Firefox(firefox_profile=fp)

【讨论】:

  • 我正在使用 FirefoxProfile 但它仍然将该配置文件文件夹复制到 /tmp/rust_mozprofile... 我检查了 geckodriver.log ,我看到了这个:运行命令:“/usr/bin/firefox”“ -marionette" "-profile" "/tmp/rust_mozprofile.ZeoXTluZ5ZCT" 如何停止创建配置文件文件夹,或者至少将其移动到另一个文件夹。因为我同时创建了许多 Xvfb 进程,而引导分区很小,所以它使硬盘满了
  • 这一行fp = webdriver.FirefoxProfile('specify location to profile .default') 将复制您在该位置的任何配置文件,将其粘贴到/tmp/rust_mozprofileasdf123,然后驱动程序将使用此复制版本的配置文件。
猜你喜欢
  • 2018-02-15
  • 2017-11-12
  • 1970-01-01
  • 1970-01-01
  • 2016-12-06
  • 1970-01-01
  • 2017-05-11
  • 2021-03-25
  • 2019-03-15
相关资源
最近更新 更多