Skip to content

Instantly share code, notes, and snippets.

@natlownes
Created November 29, 2011 15:03
Show Gist options
  • Save natlownes/1405102 to your computer and use it in GitHub Desktop.
Save natlownes/1405102 to your computer and use it in GitHub Desktop.
javascript alert box rspec matcher for selenium
Spec::Matchers.define :be_displaying_alert do
match do |actual|
class_name = begin
actual.driver.browser.switch_to.alert.class
rescue => exception
exception.class
end
class_name == Selenium::WebDriver::Alert
end
failure_message_for_should do |actual|
"Alert box not displayed."
end
failure_message_for_should_not do |actual|
"Alert box displayed. Don't wanna see that."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment