So I want to wait
until an alert is displayed, and then the usual switch
to alert and get text
The solution in Java has been provided Selenium 2 (WebDriver): check that text exists before calling Alert.getText()
Currently I use sleep
but everyone knows how bad that is.
This is what i have -
sleep 3
a = $driver.switch_to.alert
begin
a.text == 'Your alert here.'
rescue
verify { assert_match "true","false","The alert failed to be displayed"}
end
a.accept
I am looking for something like
$wait.until { a = $driver.switch_to.alert }
begin
a.text == 'Your alert here.'
rescue
verify { assert_match "true","false","The alert failed to be displayed"}
end
a.accept
But that does not work, it basically ignores the wait (I have a 30 second wait btw).
As I mentioned, I need to know how to do it in RUBY - Test Unit