I was doing tests with Caplybara
, Cucumber
and WebDriver
, so I looked at two elements on top of each other, so I thought.
The structure is simple
<div id="father-parent">
<p id="children-0">Firt element</p>
<p id="children-1">Second element</p>
</div>
If what you're trying to verify is that children-0 comes right before children-1 you can use the CSS adjacent sibling selector
expect(page).to have_css('#children-0 + #children-1')
If you just want to verify that children-0 is a prior sibling of children-1 (not necessarily adjacent) you can use the general sibling selector
expect(page).to have_css('#children-0 ~ #children-1')