In one of my views I have this link:
link_to 'Destroy', team, :method => :delete, :data => { :confirm => 'Are you sure?' }
In my rspec feature spec I want to simulate clicking on the "OK" button. I thought I could do this:
page.accept_alert 'Are you sure?' do
click_button('OK')
end
but that results in:
Failure/Error: page.accept_alert 'Are you sure?' do
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#accept_modal
What is the correct way to do this with rspec and capybara?
As the error states, the driver you are using in Capybara doesn't support the modal API. If you're using rack-test it's because it doesn't support JavaScript at all so modals don't happen anyway. If you're using poltergeist it's because they haven't released a version with support for the Capybara modal API yet - see https://github.com/teampoltergeist/poltergeist/pull/516
I think it's confirm window not alert
page.accept_confirm do
click_button('OK')
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With