我正在试验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.
我已经对此进行了一些尝试,但是还没有找到解决方案。我真的很感谢任何提示。
非常感谢,-V
一种解决方案是更改WebDriver的Firefox配置文件,以将某些MIME类型自动下载到给定目录。
我不确定如何(或是否)在Python中公开此信息,但在Selenium Wiki 上的“ Ruby绑定”页面(在“调整Firefox首选项”下)中已提及。