-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Labels
Description
Is your feature request related to a problem?
I need to mock API responses for testing but Robot Framework Browser only supports recording HAR files, not replaying them. Currently, I can record network traffic with recordHar in New Context, but there's no way to use that HAR file to mock responses in subsequent test runs.
This means I cannot:
- Test applications offline with previously recorded traffic
- Create reproducible tests with consistent API responses
- Mock backend APIs while testing frontend independently
Describe the solution you'd like
Expose Playwright's routeFromHAR() functionality through new Robot Framework keywords. Playwright already supports this - it just needs to be exposed.
Proposed Keywords
2. Route Context From HAR (context-level)
Route Context From HAR
[Arguments] path url=${NONE} update=${False} notFound=abortExample Usage
*** Test Cases ***
# Step 1: Record HAR (first run)
Record API Traffic
${har} = Create Dictionary path=./api.har
New Context recordHar=${har}
New Page https://example.com
Click text=Load Data
# Network traffic recorded
# Step 2: Replay HAR (subsequent runs)
Test With Mocked Data
New Context
Route Context From HAR path=./api.har url=**/api/**
New Page https://example.com
Click text=Load Data
# Requests to /api/** served from HAR file (offline, fast, consistent)Additional context
- Playwright Documentation: https://playwright.dev/docs/mock#replaying-from-har
- Playwright API: