如何使用 cucumber/capybara 测试文件下载对话框
我四处搜索,找不到如何使用水豚/黄瓜测试文件下载框?
下图更清楚地提出了这个问题。
I searched around and couldn't find how to test a file download box using capybara/cucumber?
The following image asks the question much clearer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这与我刚刚回答的另一个问题类似,希望它有帮助任何人都知道如何使用测试文件下载黄瓜?
This was similar to another question I just answered, hope it helps Anybody have idea how to test file download using cucumber?
@Millisami Capybara::NotSupportedByDriverError 已为我修复!
我要做的就是从我的黄瓜测试中删除 @javascript 标签,该测试已包含在内。我的意思是:
@search
场景:接收文件
...
而不是
@search
@javascript
场景:接收文件
...
希望有帮助:-)
@Millisami Capybara::NotSupportedByDriverError Fixed for me!
What i had to do is removing the @javascript tag from my cucumber test, which was included. I mean:
@search
Scenario: Recieving a file
...
instead of
@search
@javascript
Scenario: Recieving a file
...
Hope it helps :-)
下载框是浏览器的一个功能。 Capybara 模拟一个浏览器,但没有所有的 UI 等(例如,对于您的应用程序来说,它看起来像一个浏览器,因此使用它您通常会跳过整个文件下载 UI 的内容。对于浏览器来说,它看起来就像有人做了他们想要的任何事情)需要告诉浏览器将文件放在哪里并开始下载)
如果您正在尝试测试下载框(除了开始下载所需的点击之外),您现在正在测试浏览器,而不是您的应用程序。就像你自己一样,如果这是你章程的一部分并且值得你花时间。
要实际测试下载框,您必须有一个浏览器实例,并使用 Firewatir/Watir 或 Selenium 等工具来实际“驱动”浏览器,并使用其他一些 gem 在操作系统 UI 级别实际自动化(在 Windows 上我们通常使用 autoit)以便单击内容并填写浏览器文件下载 UI 的值。
The download box is a function of the browser. Capybara simulates a browser but without all the UI etc.. (e.g. it looks like a browser to your application, so using it you'd mostly skip over the whole file download UI stuff. It would look to the browser like someone did whatever they needed to in order to tell the browser where to put the file and start the download)
If you are trying to test a download box, (beyond clicks needed to start the download) you are now testing the browser, not your application. As yourself if that's part of your charter and worth your time.
To actually test the download box you are going to have to have a browser instance going, and use a tool like Firewatir/Watir or Selenium, to actually 'drive' the browser, and some other gem to actually automate up at the OS UI level (on windows we usually use autoit) in order to click things and fill in values of the browser's file download UI.