| 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access