Created
November 30, 2011 07:56
-
-
Save kyamaguchi/1408387 to your computer and use it in GitHub Desktop.
Confirmation in integration test
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
# selenium-webdriver (2.12.2) (with rails3) | |
def assert_confirmation(message, choice = 'ok') | |
if selenium? | |
assert_equal message, page.driver.browser.switch_to.alert.text | |
if choice == 'ok' | |
page.driver.browser.switch_to.alert.accept | |
elsif choice == 'cancel' | |
page.driver.browser.switch_to.alert.dismiss | |
end | |
else | |
assert true | |
end | |
end | |
# old selenium webdriver (with rails2) | |
def assert_confirmation(message, choice = 'ok') | |
if selenium? | |
assert selenium.is_confirmation_present | |
assert_equal message, selenium.get_confirmation | |
if choice == 'ok' | |
selenium.choose_ok_on_next_confirmation | |
elsif choice == 'cancel' | |
selenium.choose_cancel_on_next_confirmation | |
end | |
else | |
assert true | |
end | |
end | |
assert_confirmation("よろしいでしょうか") if selenium? | |
# http://stackoverflow.com/questions/2828342/capybara-selenium-and-javascript-destroy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment