In my app I have a page that pops up a modal that will update some content in it and dismiss itself (and become invisible) after uncertain amount of time. In my spec, I am trying to wait until the modal dismisses. My strategy is to have Capybara wait for the content on the modal to become invisible by doing
expect(page).to have_css('.hidden-element', visible: :hidden, text: 'Hidden Content')
However, it looks like Capybara won't be able to get the text of a hidden element, and I am getting the error:
expected to find css ".hidden-element" with text "Hidden Content" but there were no matches. Also found "", which matched the selector but not all filters.
It would pass if I do :all
or false
, but that's not what I want:
expect(page).to have_css('.hidden-element', visible: :all, text: 'Hidden Content')
Given that I could not change my app, I wonder why that didn't work or what the best way is to achieve that in this case. Thanks!
I am using RSpec, Capybara, Capybara-webkit.
visible: :hidden
andtext: '1234'
are mutually exclusive, and they work perfectly alone. – Hue