Skip to content

Instantly share code, notes, and snippets.

@nowk
Created September 25, 2011 16:52
Show Gist options
  • Save nowk/1240831 to your computer and use it in GitHub Desktop.
Save nowk/1240831 to your computer and use it in GitHub Desktop.
def intercept_alert(confirm = false)
begin
# TODO dismiss vs accept
# page.evaluate_script('window.confirm = function(msg) { return true; }')
# page.driver.browser.switch_to.alert.accept
page.driver.browser.switch_to.alert.dismiss
rescue Selenium::WebDriver::Error::NoAlertOpenError
# /
end
end
@nowk
Copy link
Author

nowk commented Sep 25, 2011

Had issues with Selenium unresponsive script alerts that kept popping up. This caused the feature to timeout and fail the test due to timeout errors.

Call intercept_alert before the areas of trouble. Have not seen multiple unresponsive script alerts, so not sure what the affect on that context would be.

*note, most of my problems with the unresponsive script have been with chained javascript tests, where multiple ajax requests may be involved.

Also, changing the max-timeouts in about:config for Firefox did not help, as some suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment