Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:569969
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
With this code:
 
browser.link(:text, "Move questions to...").click
 
browser.alert do
browser.button(:id => "alert").click
end #=> "the alert message"
 
I get this error:
 
/Users/riccardotacconi/.rvm/gems/ree-1.8.7-2010.01/gems/watir-webdriver-0.0.9/lib/watir-webdriver/elements/element.rb:182:in `assert_exists': unable to locate element, using {:tag_name=>"button", :id=>"alert"} (Watir::Exception::UnknownObjectException) from /Users/riccardotacconi/.rvm/gems/ree-1.8.7-2010.01/gems/watir-webdriver-0.0.9/lib/watir-webdriver/elements/element.rb:65:in `click' from watir.rb:183 from /Users/riccardotacconi/.rvm/gems/ree-1.8.7-2010.01/gems/watir-webdriver-0.0.9/lib/watir-webdriver/extensions/alerts.rb:24:in `alert' from watir.rb:182
 
Solved by intercepting the error, but it is a dirty hacks (in .rvm/gems/ree-1.8.7-2010.01/gems/watir-webdriver-0.0.9/lib/watir-webdriver/extensions/alerts.rb:24):
 
def alert(&blk)
execute_script "window.alert = function(msg) { window.lastAlert = msg; }"
begin
yield
rescue
# nothing
end
execute_script "return window.lastAlert"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.