在黄瓜测试中使用水豚查找下载框元素
我有一个下载文件的链接。当我单击链接时,它会显示带有“保存”和“打开”选项以及“取消”和“确定”按钮的对话框。我想找到黄瓜测试的“确定”和“取消”按钮。
我从下面的链接获取了帮助,但没有多大帮助。
**features code** And I want to click "OK"
**steps code** Then /^I want to click "([^\"]*)"$/ do |option| retval = (option == "OK") ? "true" : "false" page.evaluate_script('window.confirm = function() { return true; }') page.click("OK") end
I have a link that downloads a file. As I click the link it displays dialog box with "save" and "open" option and "Cancel" and "OK" button. I want to find "OK" and "Cancel" button for cucumber test.
I took help from below link but didn't helped much.
How to test a confirm dialog with Cucumber?
**features code** And I want to click "OK"
**steps code** Then /^I want to click "([^\"]*)"$/ do |option| retval = (option == "OK") ? "true" : "false" page.evaluate_script('window.confirm = function() { return true; }') page.click("OK") end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您所谈论的对话实际上根本不是网页的一部分。它是浏览器的一部分。实际上,用户界面的这一部分超出了网页的控制范围。
您可以测试的只是网页上请求下载的点,浏览器随后对该请求执行的操作不是您可以使用 cuke 编写的脚本。
对不起。
The issue is that the dialogue you are talking about is not actually a part of the webpage at all. its part of the browser. Really, that part of the user interface it outside the control of the webpage.
All you can test is the webpage UP to the point of requesting the download, what the browser does with that request subsequently is not something you can script with cuke.
Sorry.