I'm trying to write a test. There is a site with an element and a delete-button, to delete that element. If done manually, it works as expected.
Currently, the test looks like this:
visit "/argumentation#!/overview"
expect(page).to have_content("Philosophie")
save_screenshot
click_button "Delete"
save_screenshot
click_button "Yes, delete it!"
save_screenshot
sleep 5
save_screenshot
expect(page).not_to have_content("Philosophie")
(Pictures of the screenshots are below).
To make sure, that click_button "Yes, delete it!"
is actually the same button as displayed in the popup, I added click_button "Yes, delete it!"
before the click_button "Delete"
-action. This would happen:
Capybara::ElementNotFound:
Unable to find button "Yes, delete it!"
Does anyone know, why the test is failing?
In other stackoverflow-questions, some asked about the configuration in rails_helper.rb, here is mine:
Capybara.javascript_driver = :poltergeist
Capybara.default_driver = :poltergeist
I figured it out: The click_button "Yes, delete it!" is happening too fast. With a delay, it works: