17Jul/08Off
Q. How do I check if text exists in browser?
A. Use the .include? method or a regular expression ...
Example html:
<p> watir does not go well with furry little animals </p>
Example watir:
puts "Text 'watir' DOES exist" if @b.text.include? 'watir' puts "Text 'regex' DOES NOT exist" unless @b.text =~ /regex/ puts "Text 'furry little animals' DOES exist" if @b.text.include? 'furry little animals' puts "Text 'furry animals' DOES NOT exist" unless @b.text.include? 'furry animals'
Any character(s) placed between the apostrophe's will be searched for. The response will return true if found, and false if not found.