Testing javascript alerts with Capybara

I am using Cucumber + capybara + selenium to run automatic testing, but it is difficult for me to find a way to assert that a javascript warning is displayed.

This question seems to have a solution with selenium, but I can't figure out how to name the selenium object using Capybara.

Is there an easy way to check alerts with Capybara? Or is there a workaround?

+5
source share
1 answer

I tried to do this, but Capybara does not support it. Capybara ships with Selenium 2.0, not Selenium RC (as indicated in the page ), which is a library that supports this method.

Using it with Cucumber outside of Capybara involves loading and initializing the selenium-client driver. I assume that you use it in the context of Rails, so setting up the environment will be required, I'm not sure how much this works, but I would say that it is not worth the hassle.

If you are concerned about the alerts generated by link_to ...: confirm => "Are you sure?" and similar ones, don't worry, Cucumber provides a good workaround for those who have pseudo-js emulation.

0
source

All Articles