处理"下载"窗口火狐的webdriver [英] Handling "Download" window by Firefox WebDriver
问题描述
我与Firefox的webdriver的实验,我想问问是否可以办理下载窗口(接受或拒绝传入的下载请求)?
I'm experimenting with Firefox's WebDriver and I'd like to ask if it is possible to handle "Download" window (to accept or decline incoming download request)?
例如,简单的一块code的:
For example, simple piece of code:
import selenium.firefox.webdriver
dr = selenium.firefox.webdriver.WebDriver()
# Firefox is showed up.
# Let's say I'd want to download python.
dr.get('http://python.org/ftp/python/3.1.3/python-3.1.3.msi')
# Download window is showed up.
# How could I accept the download request?
# As I understand, the method below should return
# two handles but I get only main window's handle.
handles = dr.get_window_handles()
# Seems like WebDriver cannot "see" this popup.
我这个试验一点点,但还没有找到解决办法。我真的AP preciate任何暗示。
I've experimented with this a little bit but haven't found the solution yet. I'd really appreciate any hint.
非常感谢,
- V
Many thanks, - V
推荐答案
一个解决这个正在改变的webdriver的Firefox配置文件自动下载一些MIME类型给定的目录。
One solution to this is changing WebDriver's Firefox profile to automatically download some MIME types to a given directory.
我不知道如何(或是否),这是在Python中暴露出来,但它的的对硒维基Ruby绑定页面(调整火狐preferences下)。
I'm not sure how (or if) this is exposed in Python, but it's mentioned on the Ruby bindings page on the Selenium wiki (under "Tweaking Firefox preferences").
这篇关于处理"下载"窗口火狐的webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!