vendredi 11 septembre 2020

Capybara / RSpec Ensure somethinng does not exist anywhere on the page

I want to find out how to ensure something does not exist on the page, specifically, a div with a known value. Essentially, I'm removing an element and I want to test that the element with 3 classes does not exist anywhere on the page, also there are multiple elements with the same classes, so the important part is making sure the inner of the div tag does not exist.

For example:

<div class="blah blah2 blah3">my pizza</div>

There may be 20+ divs with the same classes blah blah2 and blah3, however, I need to ensure that NONE of them include the term "my pizza", how can I do this with an expect()?

I tried something like this but it didn't work:

expect(all(:css, 'div.blah blah2 blah3').value).not_to eq('value'))

Any ideas? Tips?

UPDATE: I tried adding assert_no_text('my pizza') but this checks the whole page and I don't know if this will change in a future release of the software.

Aucun commentaire:

Enregistrer un commentaire