I am trying to run a script where I open a web page and look for a specific element. If the element is present I would like to put 'Element Found', if the element is not present put 'Not Found'. I always get the error 'Unable to locate element'
I've tried to follow the advice here but it is still not working. I think this is something relatively easy, but I really don't get what I'm doing wrong:
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for:firefox
driver.manage.timeouts.implicit_wait = 5
driver.get 'http://www.example.com'
case driver.find_element(:class_name,'example').displayed?
when true
puts 'ELEMENT FOUND'
when false
puts 'NOT FOUND'
end
with if statement:
#the rest is identical as in the above example
if (driver.find_element(:class_name,'example').displayed?)
puts 'ELEMENT FOUND'
else
puts 'NOT FOUND'
end