Skip to main content

API diagnostics for single-page applications

Paxter can capture the API responses that a browser workflow observes. This is useful when a single-page application shows a generic message such as “Unable to save”, but the backend response explains the real problem—for example, that a required field was omitted.

There is no separate SPA browser mode. Enable ApiDiagnostics in the workflow and target the API route that matters. Paxter subscribes to browser network responses before the workflow starts, so it works for fetch and XHR requests made by common SPA frameworks.

Example: turn an API validation error into a regression check​

This example fills the two fields available in the UI. The API endpoint is expected to reject the request if a required backend field is missing. A 400 or 500 response causes the Paxter run to fail and preserves the response evidence.

Headless: true
NeedVideo: false
ApiDiagnostics:
Enabled: true
# Use the narrowest route that identifies this operation.
UrlPatterns:
- "**/api/customer-profiles"
CaptureResponseBody: true
FailOnErrorResponse: true
ResponseWaitMilliseconds: 1000
MaxResponseBodyCharacters: 8000
RedactJsonProperties:
- password
- token
- accessToken
- refreshToken
- authorization
- cookie
- secret
- clientSecret
- apiKey
Actions:
- Do: Page_GotoAsync
Data1: https://your-approved-test-environment.example/customer-profile
- Do: GetByLabel_Fill
Data1: Given name
Data2: Test
- Do: GetByLabel_Fill
Data1: Family name
Data2: Person
- Do: GetByRoleButton_ByName_Click
Data1: Save
# Wait for the UI result that your users should see. This also gives the API call time to finish.
- Do: GetByText_Exact_Click
Data1: Unable to save

For this workflow, a response such as 400 Bad Request with a JSON validation message appears in the HTML report’s API diagnostics tab. The run also becomes a failed regression result because FailOnErrorResponse is enabled.

Network traffic per workflow action​

Use NetworkTraffic when you need a lightweight timeline of browser requests, responses, and browser-level request failures for a site. Every event is associated with the Paxter action active when the event was observed. This makes it practical to compare a failed run with a healthy run and see which click or navigation triggered an unexpected route, status, or failed asset/API request.

Headless: true
NeedVideo: false
NetworkTraffic:
Enabled: true
# Scope this to an approved site or service. Empty records all browser traffic.
UrlPatterns:
- "https://your-approved-test-environment.example/**"
IncludeQueryString: false
# A short observation window after every Paxter action.
ActionWaitMilliseconds: 250
# Observe work that begins shortly after the final action.
FinalWaitMilliseconds: 1000
# Make browser transport failures (for example DNS, CORS, or a disconnected request) regressions.
FailOnRequestFailure: true
Actions:
- Do: Page_GotoAsync
Data1: https://your-approved-test-environment.example/customer-profile
- Do: GetByRoleButton_ByName_Click
Data1: Save

NetworkTraffic records metadata only: time, workflow step, action name, event kind (request, response, or requestfailed), HTTP method, route, resource type, status, content type, and browser failure text. It is intentionally not a HAR export and does not store request/response bodies or headers. Use ApiDiagnostics alongside it when you need a bounded, redacted API response body.

SettingDefaultMeaning
EnabledfalseTurns network-timeline collection on.
UrlPatternsEmptyURL globs to record. * matches within one path segment and ** matches across segments. Empty captures all browser traffic, so scope this in most workflows.
IncludeQueryStringfalseIncludes query strings in the timeline. Keep it off unless values are safe to retain.
ActionWaitMilliseconds250Bounded observation window after each workflow action. Allowed range: 0–10,000 milliseconds.
FinalWaitMilliseconds1000Bounded final observation window after the last action. Allowed range: 0–10,000 milliseconds.
FailOnRequestFailurefalseFails the run when the browser reports a request failure. It does not fail ordinary HTTP 4xx/5xx responses; use ApiDiagnostics.FailOnErrorResponse for that.

When events are captured, Paxter adds a Network traffic tab to index.html, writes network-traffic.json, and includes the entries in output.json. The JSON contains no body or header values and is a useful structured input for regression comparisons or an AI-assisted investigation.

API response settings​

SettingDefaultMeaning
EnabledfalseTurns collection on. Nothing is captured unless this is true.
UrlPatternsEmptyURL globs to capture. * matches within one path segment and ** matches across segments. When empty, Paxter captures all fetch/XHR responses. Prefer one or more narrow routes.
CaptureResponseBodyfalseIncludes text, JSON, XML, or JavaScript response bodies in evidence. Turn it on only when the response is safe to retain.
IncludeQueryStringfalseIncludes URL query strings in evidence. Keep this off unless query values are verified safe to retain.
FailOnErrorResponsefalseFails the workflow if a captured response has an HTTP status of 400 or higher.
ResponseWaitMilliseconds1000Final bounded wait for a late response after the last workflow action. Allowed range: 0–10,000 milliseconds. A normal UI assertion after submit is still recommended.
MaxResponseBodyCharacters8000Maximum body text written per response. Allowed range: 0–100,000. Truncated bodies are marked in the report and JSON.
RedactJsonPropertiesCommon secret namesCase-insensitive JSON property names whose values are replaced with [REDACTED] before evidence is saved.

Evidence and AI-assisted investigation​

When at least one response is captured, the run folder contains:

  • index.html — a readable API diagnostics tab showing method, route, status, response type, and sanitized body.
  • api-diagnostics.json — the same sanitized structured response data, intended for a ticket or an AI-assisted investigation.
  • output.json — the full Paxter run record, including the API diagnostic entries.

Give an AI the relevant sanitized api-diagnostics.json, the failed UI step, and the intended behaviour. It can then connect a generic UI message with the backend validation result. Paxter records evidence; it does not itself infer the cause or send evidence to an AI service.

Safety and scope​

Only use this on systems you are authorised to test. API response bodies can contain personal or confidential data even when common secret field names are redacted. Paxter deliberately does not store request bodies or response headers other than the response content type, but workflow owners must still:

  • Use a dedicated test environment and non-production test data.
  • Filter to only the endpoint needed for the scenario.
  • Keep CaptureResponseBody off unless the diagnostic value justifies the retention risk.
  • Add organisation-specific field names to RedactJsonProperties.
  • Store the run folder in an approved, access-controlled location and do not commit it.

Do not enable FailOnErrorResponse for an endpoint where a 4xx response is the expected outcome unless that expected response is outside the configured URL patterns.