Using an API as a source of fixture data

Using fixtures for test data is great for environments that are highly accessible. If we need to test something other than the localhost or CI environment, where we cannot easily load fixture data into the database, we will have to use a different approach. The trick is to utilize any and all the resources we can find to make testing possible.

One of these resources is a public-facing web API. If your website has a native cell phone application or uses a lot of AJAX to load content, then our tests can have some data to test. All we have to do is interrogate the API to get an idea of the state of the application.

A common API endpoint for most e-commerce websites is a list of all the available products. This ...

Get Selenium Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.