Help Centre › Building Processes
This article describes the RPA Browser functionality to mock network responses.
For a full list of available functions, please read BROWSER functions.
Description
The BROWSER Mock network response function intercepts fetch and XHR requests matching a URL pattern and returns a custom response instead of making the actual network call. This is useful for testing, simulating API responses, or bypassing rate limits during automation.
Setting it up
To use the BROWSER Mock network response function, follow these instructions:
{{popups:rpas/add:action=browser-mock-response}}
Once on a process map:
- Navigate to the process where you would like to add the BROWSER Mock network response function
- Click on the green button's drop-down (right side of the green button labelled "Process")
- On the menu that appears, click on the "+ Activity" item
- From here you can select the BROWSER Mock network response option
- Click "Add" once you are done
Input parameters
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
| URL pattern | Yes | Text | – | URL pattern to match (substring or regex). |
| Response body | No | Text | (empty) | Response body to return (string or JSON). |
| Status code | No | Number | 200 | HTTP status code to return. |
| Content-Type | No | Text | application/json | Content-Type header for the mocked response. |
| Variable | No | Text | mock_response | Variable name to store mock configuration. |
Output variables
| Variable | Type | Description |
|---|---|---|
| {mock_response} | Object | Object with pattern, status, and active fields. |
Errors
| Error | Description |
|---|---|
| Browser not open | No browser session is active. |
Tips
- Set up mocks before navigating to the page that makes the requests.
- Use Clear response mocks to remove all mocks and restore normal behaviour.
- Multiple mocks can be active at the same time for different URL patterns.
- Useful for testing error scenarios by returning 4xx or 5xx status codes.