Webdriver | IE9 |设置自动下载文件 [英] Webdriver | IE9 | Setup auto-download files

查看:137
本文介绍了Webdriver | IE9 |设置自动下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试下载操作。我已经配置了FF和Chrome浏览器的远程webdrivers,自动下载文件,没有任何承诺和弹出窗口。但是我找不到任何有用的信息 - 如何允许文件自动下载IE9。



我曾尝试过:




  • 找到配置驱动程序本身的任何可能的方法。找不到:没有功能,没有选项,没有cmd参数

  • 在安全选项卡中查找设置。我已经检查过,发现IE9中已经删除了这个设置。

  • 使用这样的注册表项,但并没有帮助(发现它 here ):




HKEY_CURRENT_USER\Software\Microsoft\Windows\\ \\CurrentVersion\Internet
设置\Zones\2202 = 0x0


,而这个:


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
Explorer \Main\FeatureControl\FEATURE_RESTRICT_FILEDOWNLOAD\iexplore.exe = 0x00000000


谁知道如何解决?是真的吗?

解决方案

不幸的是,我最近也碰到了这个问题。我不敢说这不是一个好消息。



IE8及以下版本,这是不同的,只是因为它是一个可以与之互动的新窗口。

IE9,现在是内置的框架通知栏



您可以使用PInvoke点击保存按钮...本主题:



https://stackoverflow.com/a/8532222/ 1173729



这个答案是Watin,但是Watin已经封装了获取特定浏览器窗口的句柄的能力的唯一区别。这可以简单地用你自己的方法切换,点通常只是得到IE的窗口的句柄,沿着它的子元素,直到你点击保存按钮。这有一个主要的缺点,尽管将控制权切换回Selenium - 它不会发生,Selenium只会挂起。



注意,这一切都在C#中。 Java显然有其他的方式,像机器人类:



http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html



我没有使用它们,但您可以使用该类将其引导到保存按钮的位置。



没有注册表项或设置来避免这个问题 - 这根本就不可能。



我已经做出了这样的决定:自从FF& Chrome可以设置为自动下载文件,之后可以验证它的存在。您测试该文件可以下载,并显示在硬盘驱动器上。



在IE9中不会发生什么机会,如果Chrome可以正常工作和Firefox?



底线是一个操作系统对话框,不在Selenium范围之内。



您还可以将其与AutoIT结合使用。我的经验是AutoIT也可以像片状一样。


I need to test download action. I've already configured remote webdrivers for FF and Chrome browsers to download files automatically without any promts and popup-windows. But I can not find any useful information - how to allow file auto-downloading for IE9.

What I've tried:

  • find any possible ways to configure Driver itself. Found nothing: no capabilities, no options, no cmd args
  • find settings in Security tab. I have checked it already and found that settings to allow this was removed for IE9.
  • use such registry keys, but it doesn't help (found it here):

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2202=0x0

and this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_RESTRICT_FILEDOWNLOAD\iexplore.exe=0x00000000

Who knows how to solve it? Is it real?

解决方案

Unfortunately, I have also hit this problem recently. I am afraid to say it is not good news.

IE8 and below, this was different, simply because it was a new window you could interact with.

IE9, it is now a builtin 'Frame Notification Bar'

You can click the Save button using PInvoke... see this topic:

https://stackoverflow.com/a/8532222/1173729

That answer is for Watin, but the only difference it that Watin already encapsulates the ability to get the handle of a particular browser window. This can simply be switched with your own method, the point is generally just get the handle of IE's window, walk down it's child elements until you hit a 'Save' button. This has a major drawback though, switching the control back to Selenium - it doesn't happen, Selenium will just hang.

Note, this is all in C#. Java apparently has other ways, like the 'Robot' class:

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html

I have not used them, but you will be able to use the class to direct it to where the Save button will be.

There will be no registry keys or settings to avoid this problem - it is simply not possible.

I have taken the decision that since FF & Chrome can be set up to automatically download a file, you can verify it's existence afterwards. You test that the file can be downloaded and it shows up on the hard drive.

What are the chances that won't happen in IE9, if it works OK in Chrome and Firefox? Slim, but possible.

The bottom line is it's an OS dialog, something outside of the scope of Selenium.

You can also combine it with AutoIT. My experience is AutoIT can also be just as flaky.

这篇关于Webdriver | IE9 |设置自动下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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