我正在使用 firefox webdriver。我想将所有 cookie 和缓存文件存储到一个自定义目录中。但它采用临时目录而不是我的目录。这是我的代码:
FirefoxProfile firefoxProfile = new FirefoxProfile(path, false);
MessageBox.Show(firefoxProfile.ProfileDirectory); //Its showing blank
driver = new FirefoxDriver(firefoxProfile);
MessageBox.Show(firefoxProfile.ProfileDirectory); //Its showing the temp dir
//not my custom dir
如何让它获取我的目录并将所有 cookie 和文件存储在那里?
谢谢。
编辑:
我需要修复 selenium 配置文件目录(因为它一直在变化)。这样我就可以使用以前的 cookie 和缓存文件。你能给我任何想法或任何替代方法来完成它吗?
最佳答案
您可以直接找到临时文件路径,然后在创建驱动程序后使用系统命令将文件复制到此文件夹中。然后你就可以访问它们了,虽然这有点 hacky 但应该可以工作(除非我在这里错过了一些重要的东西,我觉得我可能有 :) )
关于c# - Selenium 设置偏好目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10375961/