API Intercept
Use API Intercept to capture, modify, assert, or block HTTP requests and responses during test execution. This is useful when you want to simulate or test network behaviors without depending on backend availability.
When to Use API Intercept
Use API Intercept when you need control over network behavior during test execution. Common scenarios include:
- Mocking Responses – Replace or modify backend data without changing the server.
- Simulating Failures – Trigger network errors or delays to test app resilience.
- Validating API Behavior – Check request payloads or assert response values.
- Blocking Requests – Abort unwanted calls to simulate edge cases or reduce noise.
Adding an API Intercept Step
Before you can add an API Intercept, you must run the scenario once using Playback Run. This links the recorded steps with their corresponding network logs and enables the feature.
Hover over a test step that triggered a network request, click the three-dot menu and select Intercept API.
Click Filters (+) and choose the network call you want to intercept from the list of captured logs. Use the search to narrow your selection by URL, status code, or HTTP method. Click Apply.
The tab expands to show the selected request URL (which you can edit) and an option to add query parameters as key-value pairs. Click Apply to proceed.
In the next section, choose actions such as Verify, Modify, or Abort. You can simulate a failure by selecting an abort reason from the provided list. You can also verify or change the status code. Click Save when you're done configuring the intercept.
The step now displays an API Intercept icon, and the Add API Intercept option changes to Edit API Intercept, allowing you to make further updates at any time.
This is how the Reports page displays a step that was aborted using API Intercept.
When you add an API Intercept to a step, a file is automatically created inside your project folder at:
/project/data/routes/
This file stores the filter and action details such as the URL to intercept, query parameters, and what to do with the request (abort, modify, verify, etc.). The file helps keep your test logic and API handling in sync and reusable.