Skip to content

Instantly share code, notes, and snippets.

@kucaahbe
Created March 21, 2014 15:02
Show Gist options
  • Save kucaahbe/9688195 to your computer and use it in GitHub Desktop.
Save kucaahbe/9688195 to your computer and use it in GitHub Desktop.
BROKEN: cucumber with capybara: if scenario failed and left modal alert after self: accept it and prevent other scenarios failing
# features/support/capybara_ignore_alert_after_scenario.rb
# if scenario failed and left modal alert after self
# accept it and prevent other scenarios failing
After '@javascript' do |scenario|
if scenario.failed?
# exception for modal dialogs
# http://rdoc.info/gems/selenium-webdriver/Selenium/WebDriver/Error/UnhandledAlertError
if scenario.exception.instance_of?(Selenium::WebDriver::Error::UnhandledAlertError)
page.driver.browser.switch_to.alert.accept
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment