The following works as expected:
within('h2', text: 'foo') do
should have_content 'bar'
end
I am trying to check within the parent element, using find(:xpath, '..')
Once you find an element, how to apply .find(:xpath, '..'), and then check for something within that element?
When you use XPath locator inside
withinit should start with.(if it doesn’t start with.the search is done not within.myclassbut within the whole document).E.g.:
or:
Code from @BSeven’s answer can be written in one line:
or