如何使用webdriver-selenium从IE浏览器下载文件 [英] How to download a file from IE browser using webdriver-selenium

查看:3819
本文介绍了如何使用webdriver-selenium从IE浏览器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用webdriver实现我的Web应用程序的下载文件功能。在chrome或firefox中,我们可以设置将文件下载到定义的位置,点击下载按钮,而不需要任何窗口提示。

I am trying to implement a download file functionality for my web application using webdriver. In chrome or firefox, we can set the capability to download the files to a defined location upon clicking download button without any window prompt.

但是在IE 9中,找到下载选项的任何功能设置。

But in IE 9, I don't find any capability setting for download options.

此外,在IE中点击下载按钮后,webdriver挂起窗口提示后保存/打开/取消。点击操作后,Webdriver不返回任何内容。我不得不退出webdriver并重新创建webdriver对象继续下一步。

Also after clicking on download button in IE, webdriver is hanging after window prompt for save/open/cancel. Webdriver doesn't return anything after click operation. I had to quit webdriver and re-create the webdriver object to proceed with next step.

要处理窗口提示,我尝试使用Sikuli /发送关键方法等。这些工作只有当窗口处于焦点时。当我运行具有机器锁定或通过Jenkins远程运行的脚本时,它不起作用。

To handle the window prompt, I tried using Sikuli/send key methods etc. All these works only when the window is in focus. It doesn't work when I run the script having machine locked or run through remote like via Jenkins.

如何配置IE否提示保存选项,但下载文件任何预定义的路径。像IE8一样,我们可以设置regedit设置下载路径。

How can I configure IE no to prompt save option but download file to any predefined path. Like in IE8, we can set the regedit to set download path.

推荐答案

Selenium throws 模态对话框如果文件下载弹出窗口出现异常。有时候,webdriver会根据弹出窗口后浏览器上的操作挂起。

Selenium throws Modal dialog Present exception if file download popup present. Some times webdriver hangs out based on operations perform on the browser after popup present.

如果需要,您可以通过注册表手动执行:
http://9to5it.com/internet-explorer-disable-do-you-want-to-open -or-save-this-file-prompt /

You can do it manually through registry if you want: http://9to5it.com/internet-explorer-disable-do-you-want-to-open-or-save-this-file-prompt/

如果您使用Java作为编码语言,可以使用 Robot class。请参考以下链接。
如何使用Selenium下载.docx文件webdriver in Java?

If you are using Java as coding language, you can use Robot class. Please refer below link for example. How to download .docx file using Selenium webdriver in Java?

c#中没有类,因为机器人 class Java 。我正在使用 AutoIT 来处理Windows弹出窗口。

There is no class in c# as Robot class in Java. I am using AutoIT to handle windows popups.

希望这有帮助。

这篇关于如何使用webdriver-selenium从IE浏览器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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