| Recipe 30 | Parse HTML Tables |
Problem
You’re testing a web page containing tabular data (or any repeating data, really), and you need to compare the contents to a table in your Cucumber scenario.
Ingredients
-
Capybara[193] for testing web applications
-
Capybara’s arsenal of finders[194] for traversing patterns in HTML
-
XPath[195] for describing the locations of objects on the page
Solution
Capybara is a Ruby web testing library. It provides a simple API for visiting web pages and parsing the results. Behind the scenes, Capybara will either launch a real browser (for non-Ruby web apps) or call directly into the server code (for Ruby apps built on Rails, Sinatra, or any other Rack framework).
In this recipe, you’ll serve a simple static site ...