开发者

Testing for javascript alerts with Capybara

开发者 https://www.devze.com 2022-12-29 01:37 出处:网络
I\'m using Cucumber + capybara + selenium to run automated testing, but I\'m having trouble finding a way to assert that a javascript alert is displayed.

I'm using Cucumber + capybara + selenium to run automated testing, but I'm having trouble finding a way to assert that a javascript alert is displayed.

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

Is there a simple way to test for alerts using Capybara? Or is there a workaroun开发者_开发技巧d?


I've tried to do it, but Capybara doesn't support it. Capybara comes with Selenium 2.0, not Selenium RC (as stated in the page), which is the library that supports that method.

Using it with Cucumber outside of Capybara involves loading and initializing the selenium-client driver. I assume you are using it within the context of Rails, so it will require setting up the environment, I'm not sure how much work is this, but I'd say is not worth the hassle.

If your concern are the alerts created by the link_to ... :confirm => "Are you sure?" and similar, don't worry, Cucumber provides a nice workaround for those with some pseudo-js emulation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号