How to accept or deny JavaScript confirmation dialogs in Capybara/Selenium

Updated . Posted . Visible to the public.

These methods are available to you:

page.driver.browser.switch_to.alert.accept
page.driver.browser.switch_to.alert.dismiss
page.driver.browser.switch_to.alert.text # the confirmation text

Spreewald Show archive.org snapshot gives you steps like these:

When I confirm the browser dialog
When I cancel the browser dialog

Also see Type text into Javascript prompt dialogs in Capybara/Selenium.

Dominik Schöler
Last edit
Michael Leimstädtner
Keywords
capybara, cucumber, modal, dialogue
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2011-09-05 14:43)