处理Firefox WebDriver的"下载"窗口

Vit*_*liy 2 python selenium automation webdriver

我正在尝试使用Firefox的WebDriver,我想询问是否可以处理"下载"窗口(接受或拒绝传入的下载请求)?

例如,简单的代码:

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.
Run Code Online (Sandbox Code Playgroud)

我已经尝试了一点,但尚未找到解决方案.我真的很感激任何提示.

非常感谢, - V.

jar*_*rib 5

解决此问题的一种方法是将WebDriver的Firefox配置文件更改为自动将某些MIME类型下载到给定目录.

我不确定它是如何(或者是否)在Python中公开的,但它在Selenium wiki 的Ruby绑定页面上提到(在"Tweaking Firefox preferences"下).