Vatir: How to check the text is not present on the web page

I am writing a test where I delete a record and I need to check that the record no longer appears after deleting it. I know how to verify that the text of the entry is present on the page with "browser.text.include?", But is there a way to verify that the text is not present? I need the test to fail if the text is still present after it was supposedly deleted. I searched, but the only hits I find in the search tell me how to check the text which is the opposite of what I need.

Thank you very much.

+4
source share
4 answers

browser.text.include? returns a boolean value (actually truetype or falsetype, but this is not the time for this discussion), so its negation inverts your search.

do_a_faily_thing if not browser.text.include? "badgers are eating my face" 

Feel free to customize for your needs. PS. This is basically the answer, only with carnal badgers.

Added for historical interest, from Chuck's suggestion:

 do_a_faily_thing unless browser.text.include? "face-eating-badger-eating-badgers are eating my face-eating badgers" 

Added "else" example:

 if browser.text.include? "badgers are eating my face" do_a_thing else phew_no_badgers end 
+4
source

What about:

  !browser.text.include?("my string") 
+2
source

or depending on what kind of testing framework you are using

 # RSpec and/or Cucumber browser.text.include?("my string").should != true # TestUnit assert(browser.text.include?("my string") != true) 
+2
source

If the entry is wrapped with an HTML element, use an existing one? method is another way to verify existence.

remote recording (sample)

 <p class='foo'>bar</p> 

check script

 p(:class,'foo').exist? 
0
source

Source: https://habr.com/ru/post/1347942/


All Articles