是 Firefox 还是 Geckodriver,它创建 "rust_mozprofile" 目录

Is it Firefox or Geckodriver, which creates "rust_mozprofile" directory

每当我们调用 Firefox 时,都会在“/tmp”目录下创建 rust_mozprofile 目录。由于 Firefox 在内部调用 Geckodriver,我们不确定是 Firefox 还是 Geckodriver 正在创建 rust_mozprofile 目录。

我想知道是 Geckodriver 还是 Firefox,因为我的“/tmp”目录内存不足。

所以问题是我很想修改rust_mozprofile的创建目录路径。

我正在使用以下技术,

如果有建议,请给我们一些建议。

如果您仔细查看 geckodriver v0.18.0 日志,您会发现 rust_mozprofile 的第一次出现出现在以下行中:

1504762617094   Marionette  CONFIG  Matched capabilities: {"browserName":"firefox","browserVersion":"56.0","platformName":"windows_nt","platformVersion":"6.2","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":5848,"moz:profile":"C:\Users\AtechM_03\AppData\Local\Temp\rust_mozprofile.OfFuR9ogm33d","moz:accessibilityChecks":false,"moz:headless":false}

此日志清楚地表明 正在配置:

"moz:profile":"C:\Users\AtechM_03\AppData\Local\Temp\rust_mozprofile.OfFuR9ogm33d" 

并且此配置由 实例完成,即 GeckoDriver

它是 GeckoDriver 内部配置 Marionette 进而启动 Mozilla Firefox浏览器.

IMO,自从我们从 Legacy Firefox 迁移到基于 Marionette火狐。因此,Geckodriver - 13 也是如此。


更新:

GeckoDriver 作为 application/exe 文件:

一个解决方案是使用 driver.quit() 这将关闭所有浏览器并处理配置文件

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

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

我遇到了类似的问题,我通过更改 Windows 中的环境设置解决了这个问题。这意味着我更改了 TMP 和 TEMP 文件的目录,重新启动后,rust_mozprofile 文件夹生成在我想要的位置。

这是我使用的来源:https://www.toolsqa.com/selenium-webdriver/how-to-use-geckodriver/ 特别是 "Set property in Environment Variables:-" 部分。

遗憾的是,这将影响所有将文件保存到这些文件夹的软件。 (不过就我而言,这正是我想要的。)如果有办法通过程序在特定目录中只创建 rust_mozprofile 文件夹,我很想了解更多。

您可以使用 TMPDIR envvar 设置位置。为其他程序同时设置 TMP 和 TEMP 也很有用。