I'm looking to test the text in an alert dialog using Capybara Webkit. I'm aware of the accept_js_confirms
and reject_js_confirms
methods, but I'm looking to evaluate the contents of the dialog prior to performing an action. In Selenium for example, the following works:
alert = page.driver.browser.switch_to.alert
expect(alert.text).to eq t('report_periods.edit.delete_confirmation')
alert.accept
I'm currently using expect(page.driver.confirm_messages).to include t('report_periods.edit.delete_confirmation')
to test the text of the same dialog, however, after updating our capybara-webkit gem our tests output a deprecation warning: [DEPRECATION] Capybara::Webkit::Driver#confirm_messages is deprecated. Please use Capybara::Session#accept_confirm or Capybara::Session#dismiss_confirm instead.
Using either of those methods from the warning will not test the contents of the dialog though.