Created
November 29, 2011 15:03
-
-
Save natlownes/1405102 to your computer and use it in GitHub Desktop.
javascript alert box rspec matcher for selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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