如何在Mozilla Marionette web驱动程序中设置特定的下载位置?

2024-04-20 10:31:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个自动化脚本,在最近的mozilla更新之前运行得很好。selenium python脚本自动执行一些浏览器操作,并将某些报告(csv)保存到定义的位置。在

我一直在使用selenium 2.53.6,它使用以下代码:

profile = webdriver.firefox.firefox_profile.FirefoxProfile()
profile.set_preference('browser.helperApps.neverAsk.saveToDisk',"text/csv, application/pdf,application/octet-stream")
profile.set_preference('browser.download.folderList',2)
profile.set_preference("browser.download.manager.showWhenStarting",False)
profile.set_preference('browser.download.dir','D:\Downloads')
driver = webdriver.Firefox(firefox_profile=profile)

目前我使用的是selenium Python3.0.1和Firefox48。在这里,我将geckodriver路径添加到环境变量中,并能够使用以下代码启动firefox:

^{pr2}$

我很好奇如何在firefox木偶驱动程序中做一个profile.set_preference等效的功能。我找不到任何关于它的文件。在

请告知。在


Tags: csv代码browser脚本mozillaapplicationdownload报告
1条回答
网友
1楼 · 发布于 2024-04-20 10:31:10

您也可以传递profile来启动^{}作为:-

driver = webdriver.Firefox(capabilities=caps, firefox_profile=profile)

也可以将firefox_profile设置为capabilities为:

^{pr2}$

相关问题 更多 >