下载文件对话框 [英] Download File Dialog
问题描述
我有花了一会儿查看处理它的方法,我发现任何相关的几件事情是 AutoIT ,更改默认下载位置&使浏览器自动下载文件,只需断言链接工作而不下载文件。不幸的是,我的情况排除了三种可能性。
- 我正在使用各种浏览器(排除自动下载,因为某些浏览器不
- 我正在使用各种平台(排除AutoIT,仅限Windows应用程序)。
- 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. 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屋!