I am trying to access some text that is located in a DIV.
I need to check to see if the page holds the text so I can return a true or false.
The code I am using is below:
cancel = browser.text.include?("Current Cancelled")
if cancel == true
puts "Line item cancelled"
else
puts "****Line item not cancelled****"
end
But it returns false every time.
Here is a code snippet of what I am looking into:
The probable reason this isn't working is because the string you're testing for contains a newline character and a non breaking space.
This could work...
if browser.div(:text, /Current.*Cancelled/).exists?
puts "Line item cancelled"
else
puts "****Line item not cancelled****"
end
or
if browser.text =~ /Current.*Cancelled/
puts "Line item cancelled"
else
puts "****Line item not cancelled****"
end
etc.