通过 Firefox WebDriver 处理“下载”窗口

2024-03-30

我正在尝试 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 中公开的,但它在Ruby 绑定页面 http://code.google.com/p/selenium/wiki/RubyBindings在 Selenium wiki 上(在“调整 Firefox 首选项”下)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过 Firefox WebDriver 处理“下载”窗口 的相关文章

随机推荐