Integrating API tests and browser tests into a plan

How to integrate API tests and browser tests within a plan

API tests can be added to a plan to set up the conditions for browser tests and, if needed, restore the environment to its original condition after browser tests execute. Data setup and teardown are good candidates to be handled by API tests for two reasons:

  1. They run faster than browser tests
  2. They can handle the parts of testing that aren't central to what you want to test.

Setup - test - teardown

By organizing a plan sequentially or by plan stages, you can create a setup-test-teardown model that speeds up the testing process and isolates your browser tests to a specific end goal.


If you want to validate that an ecommerce app is showing the correct information in a customer's order history, you could create the following setup:

  1. Setup: create one or more orders in an API test.
    • Store data about newly created orders in variables.
    • Enable variable sharing in order to pass data to a browser test.
  2. Test: Train a browser test to validate that the application order history shows the correct information.
    • Log in.
    • Navigate to the order history page.
    • Assert that the correct information appears on the order history. While training, you can use test data-driven variables as placeholder values.
    • Enable variable sharing to pass data to the subsequent API test for teardown.
  3. Tear down: create an API test that deletes the orders.
    • Assert that the delete requests return a successful status code.

Depending on the setup stage, the test stage could also include browser tests that validate additional functionality.

For example, the test phase of this example plan could include other browser tests that validated functionality related to existing orders, such as applying discount codes to an order or modifying the delivery address.

Learn more

To learn more about how to integrate API and browser tests to optimize your automated testing, check out the follow guides: