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

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

问题描述

我正在使用Selenium与我的CI系统自动测试我的各种应用程序,其中一个是一个Web表单,可下载我们的答案(作为动态生成的PDF)。测试是断言可下载的PDF文件包含正确的答案(Webform给出的答案)。我的问题是尝试处理下载对话框以检索PDF文件(声称PDF的内容正确无误此问题的范围之外)。



我有花了一会儿查看处理它的方法,我发现任何相关的几件事情是 AutoIT ,更改默认下载位置&使浏览器自动下载文件,只需断言链接工作而不下载文件。不幸的是,我的情况排除了三种可能性。


  1. 我正在使用各种浏览器(排除自动下载,因为某些浏览器不

  2. 我正在使用各种平台(排除AutoIT,仅限Windows应用程序)。

  3. PDF中的内容是基于以前与应用程序的交互动态生成,测试是断言生成的内容是否与预期值匹配,因此只需检查链接是否存在是不够的。

由于正在呈现的下载对话框由操作系统管理,我不知道是否可以使用Selenium作为我打算的内容,但是我以为我会先询问是否有人知道任何使用Selenium的解决方案,或者可以推荐一些其他可接受的测试手段?

解决方案

据我所知,使用硒,因为你的原因讨厌自己但是,我认为最好的方式是直接下载生成的pdf而不用硒。既然你知道它的url,你可以使用

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).

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. I am using a variety of browsers (ruling out the automatic downloads as some browsers do not support this).
  2. I am using a variety of platforms (ruling out AutoIT, a Windows only application).
  3. The content within the PDF is dynamically generated based on previous interactions with the application, the test is to assert whether the content generated matches the expected values, so just checking if the link exists is not enough.

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?

解决方案

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天全站免登陆