What is the best way to handle browser dialogs (with ok/cancel buttons) using capybara/selenium?
The way I found easiest is by running the following:
dialog = page.driver.browser.switch_to.alert
dialog.accept
Any thoughts for a better approach?
Whoever downed this post please give a valid reason... it's not helpful to down vote with no reason why
Where possible, you should try to avoid using the underlying driver directly. By using Capybara's API, you would be (in theory) in a better position if you want to change driver's and there are driver API differences.
From Capyabara's project page, the way to handle modal dialogs is: