[英]Click outside of a div spec with capybara
I am currently have a modal that pops up on a button click. 我当前有一个单击按钮时弹出的模式。 I have the implementation working where if a user clicks outside the main modal-dialog, that it'll close the modal.
我有实现的工作,如果用户在主模态对话框之外单击,它将关闭模态。
I am writing specs now with rspec and capybara. 我现在正在用rspec和capybara编写规范。 My before block
我的前块
before do
find("#inquiries-new").click
should_not have_content('CAMPAIGN INQUIRY')
end
I get this when I run the spec 我在运行规范时得到了这个
1) Inquiry popup close popup by clicking outside modal-dialog open again to test duplicated view
Sauce public job link:
Failure/Error: should_not have_content('CAMPAIGN INQUIRY')
expected not to find text "CAMPAIGN INQUIRY" in "Lorem Ipsum Customers Close CAMPAIGN INQUIRY NAME EMAIL COMPANY CAMPAIGN TITLE BUDGET PHONE DESCRIPTION SEND INQUIRY"
# ./spec/features/home/inquiry_popup_spec.rb:34:in `block (4 levels) in <top (required)>'
Is there a way to create a spec for this behavior? 有没有办法为此行为创建规格?
I was able to click outside of the modal by executing some javascript with capybara 我可以通过使用capybara执行一些javascript来单击模态之外
page.execute_script('$(document.elementFromPoint(50, 350)).click();')
The coordinates worked for my specific case, but others should be able to edit them for whatever suits their situation. 坐标适用于我的特定情况,但是其他人也应该能够根据自己的情况对其进行编辑。
page.find(:xpath, "//*[text()='#{text_to_click}']").click
其中, text_to_click
是模型之外的一些文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.