这个 selenium firefox 配置文件将文件下载到自定义文件夹有什么问题?

用户1315789

我正在使用 selenium 和 python v3.6 来自动化 firefox 将文件下载到自定义文件夹中。文件夹的位置是C:/Users/username/Dropbox/Inv/

以下是我的 Firefox 个人资料。

profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', 'C:/Users/username/Dropbox/Inv/')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/plain')
profile.set_preference('browser.helperApps.neverAsk.openFile', 'text/plain')

目前,该文件始终下载在默认文件夹中C:\Users\username\Downloads如何获得下载的文件夹位置C:/Users/username/Dropbox/Inv/

用户1315789

我会回答我自己的问题。问题在于指定下载目录的字符串。我应该使用\\而不是/.

profile.set_preference('browser.download.dir', 'C:\\Users\\username\\Dropbox\\Inv')

该代码已被验证现在可以工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

设置Firefox配置文件以使用Selenium和Java自动下载文件

如何在Java中将Firefox配置文件和Firefox选项与Selenium一起使用

如何阻止Selenium使用Web Driver创建临时的Firefox配置文件?

如何使用GeckoDriver Firefox和Selenium下载文件?

Selenium Python Firefox WebDriver:无法修改配置文件

需要Selenium Java中与这些(Firefox)浏览器配置文件设置相同的Chrome

Selenium Firefox配置文件不起作用

如何在Selenium C#中使用现有的Firefox配置文件?

使用Selenium 3启动特定的Firefox配置文件

Selenium-如何从现有的Firefox配置文件中导入所有设置

创建Webdriver后Selenium firefox配置文件更新下载目录

使用Firefox绕过弹出窗口下载文件:Selenium Python

Python Selenium:加载Firefox配置文件时没有此类文件或目录

应该保存深色模式设置的Javascript在Firefox的子文件夹中不起作用。如何解决这个问题?

Python和Selenium:如何多次更改Firefox的配置文件

使用Selenium和Python定义WebDriver后如何更改Firefox配置文件首选项

Python Selenium Firefox:使用Firefox配置文件时无法打开多个选项卡

加载firefox后,Selenium FireFoxDriver配置文件是否更改?

如何在使用Ruby的Selenium WebDriver远程上设置Firefox配置文件

这个配置文件做什么?

使用Python的Selenium下载文件:即使在设置Firefox配置文件后,“下载”窗口也会打开

无法使用 Selenium (geckodriver 0.16) 设置 Firefox 配置文件的首选项

你如何使用python3修复selenium的这个属性firefox错误

Selenium + Firefox + Python:下载目录问题

Selenium Chrome:加载配置文件并更改下载文件夹 - Python

这个打字稿文件中的定义有什么问题

使用 selenium 从 Firefox 自动下载 zip 文件

禁用下载弹出 Firefox Selenium

这个 PDF 文件有什么问题?