下载文件对话框 [英] Download File Dialog

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

问题描述

我用硒与我的CI系统自动测试我的各种应用,其中之一是一个Web表单与我们答案的下载副本(作为一个动态生成的PDF)。该测试是断言下载的PDF文件包含正确的答案(在网络表单给出答案)。我的问题是试图处理下载对话框检索PDF文件(断言PDF的内容是正确的是这个问题的范围)。

I'm using Selenium with my CI system to automatically test my various applications, one of which is a web form with a downloadable copy of our answers (as a dynamically generated PDF). The test is to assert the downloadable PDF file contains the correct answers (answers given on the webform). My problem is trying to handle the download dialog to retrieve the PDF file (asserting the contents of the PDF are correct is outside the scope of this question).

我已经花了关于如何处理它四处寻找了一会儿,几件事情,我发现任何相关的是的 AutoIt的,更改默认下载位置和放大器;自动使得浏览器下载文件,只是<一个href=\"http://ardesco.lazery$c$c.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/\"相对=nofollow>断言链接的作品,而无需下载文件。不幸的是,我的情况排除了所有的三种可能性。

I've spent a while looking around on ways to handle it, the few things I've found of any relevance was AutoIT, changing the default downloads location & making the browser download files automatically, and just asserting the link works without downloading the file. Unfortunately, my situation rules out all three possibilities.


  1. 我使用各种浏览器(排除自动下载一些浏览器不支持此)的。

  2. 我使用各种平台(排除AutoIt的,只有一个Windows应用程序)。

  3. 在PDF中的内容是动态生成基于与应用previous相互作用,测试断言的内容是否产生匹配预期值,所以只检查是否存在联系是不够的。

由于下载对话框幸福presented是由操作系统管理,我不知道是否有可能使用Selenium什么我打算,不过我想我会先询问,看是否有人不知道任何解决方案使用Selenium,或反而会推荐测试的其他可接受的方式?

Because the download dialog being presented is managed by the OS, I'm not sure whether it is possible to use Selenium for what I intend, however I thought I would ask first to see if anyone does know any solutions using Selenium, or instead can recommend some other acceptable means of testing?

推荐答案

据我所知,你不能使用硒,对于你说自己的理由。不过,我认为解决这个最好的办法就是直接下载生成的PDF无硒。既然你知道它的网址,你也许可以使用<一所概述的方法href=\"http://ardesco.lazery$c$c.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/\">this文章。它描述了粉猴做你想要做什么。

As far as I know you can't use selenium for that, for the reasons you stated yourself. However, I think the best way to approach this is to download the generated pdf directly without selenium. Since you know its url, you can maybe use the approach outlined in this article. It describes the use of "Powder-Monkey" to do exactly what you want to do.

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

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