Posted over 10 years ago. Visible to the public. Linked content.

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

These methods are available to you:

Copy
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 Archive gives you steps like these:

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

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

Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.

Join our free training event and learn to fix any flaky test suite, even in large legacy applications.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
9 months ago
by Dominik Schöler
Keywords:
capybara, cucumber, modal, dialogue
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more