Created
August 3, 2011 10:39
-
-
Save alisterscott/1122352 to your computer and use it in GitHub Desktop.
methods to locate elements are okay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir-webdriver' | |
def search_field browser | |
browser.text_field(:name => "q") | |
end | |
browser = Watir::Browser.new :firefox | |
begin | |
browser.goto "http://google.com" | |
#element = browser.text_field(:name => "q") | |
p search_field(browser).value # element is now located | |
browser.refresh # refreshing the page obsoletes the element | |
begin | |
p search_field(browser).value | |
rescue Selenium::WebDriver::Error::ObsoleteElementError | |
# doesn't get raised | |
end | |
# relocating the element works | |
#element = browser.text_field(:name => "q") | |
p search_field(browser).value | |
ensure | |
browser.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment