1

I want to create some front-end automation for our web application. My plan is to use RSpec as the framework and Selenium to drive the browser. I see a lot of information (blog posts) around using Capybara with RSpec + Selenium. Are there advantages to using Capybara that I don't get by using RSpec + Selenium alone?

1 Answer 1

1

I think the Capybara benefits sum it up nicely:

  • No setup necessary for Rails and Rack application. Works out of the box.
  • Intuitive API which mimics the language an actual user would use.
  • Switch the backend your tests run against from fast headless mode to an actual browser with no changes to your tests.
  • Powerful synchronization features mean you never have to manually wait for asynchronous processes to complete.

Most of these Selenium frameworks try to achieve the same things. Easier and more readable syntax, easier configuration and auto-waiting.

If you write their DSL you could also switch to other frameworks then Selenium, but capybara does not offer that yet, but it could be an advantage in the future. If a new testing method comes along let the Capybara team implement it with the same DSL. You might not even have to change your tests to use the new tech.

The downsides are that these frameworks add a layer of magic. Where if something goes wrong it is harder to debug what is going on, but they "promise" to let you develop faster. So balance the trade off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.