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

前端之家收集整理的这篇文章主要介绍了如何在Mozilla – Marionette Web驱动程序中设置特定的下载位置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个自动化脚本,在最近的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-python 3.0.1和Firefox 48.这里我添加了geckodriver路径到环境变量,并能够使用下面的代码启动firefox:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
driver = webdriver.Firefox(capabilities=caps)

我很好奇如何在firefox-marionette驱动程序中执行profile.set_preference等效操作.我找不到任何关于它的文件.

请指教.

解决方法@H_502_16@
您也可以通过个人资料发布 FirefoxDriver
driver = webdriver.Firefox(capabilities=caps,firefox_profile=profile)

您还可以将firefox_profile设置为以下功能: –

caps["firefox_profile"] = profile
driver = webdriver.Firefox(capabilities=caps)

原文链接:https://www.f2er.com/html/231821.html

猜你在找的HTML相关文章