如何在Mozilla中设置特定的下载位置 - Marionette Web驱动程序? [英] How to set a specific download location in Mozilla - Marionette web driver?

查看:180
本文介绍了如何在Mozilla中设置特定的下载位置 - Marionette Web驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  profile = webdriver.firefox.firefox_profile.FirefoxProfile()
profile.set_preference('browser。
profile.set_preference('browser.download.folderList',2)
profile.set_preference(helperApps.neverAsk.saveToDisk,text / csv,application / pdf,application / octet-stream 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:

 来自selenium import webdriver 
from selenium.webdriver.common由Matchi.com提供回到sired_capabilities import DesiredCapabilities
$ b caps = DesiredCapabilities.FIREFOX
caps [marionette] = True
driver = webdriver.Firefox(capabilities = caps)

我很好奇如何在firefox-marionette中做一个 profile.set_preference 驱动程序。

请指教

解决方案

您也可以传递个人资料来启动 FirefoxDriver 为:

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

还可以将 firefox_profile 设置为功能

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


I am having an automation script which worked well before the recent mozilla update. The selenium-python script automates some of my browser actions, and save certain reports (csv) to a defined location.

I have been using selenium 2.53.6, which uses the following code :

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)

Currently I use selenium-python 3.0.1 and Firefox 48. Here I had added the geckodriver path to environment variables and was able to launch firefox using the code below:

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

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

I am curious on how to do a profile.set_preference equivalent in firefox-marionette driver. I couldn't find any documentations on it.

Please advise.

解决方案

You can pass profile as well to launch FirefoxDriver as :-

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

You can also set firefox_profile into capabilities as :-

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

这篇关于如何在Mozilla中设置特定的下载位置 - Marionette Web驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆