O'Reilly logo

Application Testing with Capybara by Matthew Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finders, scoping, and multiple matches

A lot of the API we have covered so far in this chapter has in some ways been a bit of a façade. Capybara, in the best way possible, provides a lot of "syntactic sugar" around some basic building blocks.

These building blocks are in fact simply XPath expressions to find things on the page and then delegate the action down to the underlying driver.

Most of the time it makes sense to use this "sugared" API, as your code is made a lot more expressive and readable. Aside from the obvious benefit of "write once, run on multiple drivers", the clean semantics of Capybara's API are its main selling points so you should use it wherever possible.

However, there will be times when these methods don't work for you. For ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required