BROWSER Mock network response function

Mock network responses for URLs matching a pattern.

Help CentreBuilding 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:

  1. Navigate to the process where you would like to add the BROWSER Mock network response function
  2. Click on the green button's drop-down (right side of the green button labelled "Process")
  3. On the menu that appears, click on the "+ Activity" item
  4. From here you can select the BROWSER Mock network response option
  5. Click "Add" once you are done

Input parameters

ParameterRequiredTypeDefaultDescription
URL patternYesTextURL pattern to match (substring or regex).
Response bodyNoText(empty)Response body to return (string or JSON).
Status codeNoNumber200HTTP status code to return.
Content-TypeNoTextapplication/jsonContent-Type header for the mocked response.
VariableNoTextmock_responseVariable name to store mock configuration.

Output variables

VariableTypeDescription
{mock_response}ObjectObject with pattern, status, and active fields.

Errors

ErrorDescription
Browser not openNo 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.

Related functions

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or go live in 7 days.