Skip to content

@rtacconi /gist:569969
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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.