Reputation: 1428
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. 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?
Upvotes: 3
Views: 3196
Reputation: 1545
page.find(:xpath, "//*[text()='#{text_to_click}']").click
Where text_to_click
is some text outside your model.
Upvotes: 2
Reputation: 1428
I was able to click outside of the modal by executing some javascript with capybara
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.
Upvotes: 2