A browser test that says only navigation failed leaves three teams guessing. The proxy provider sees no obvious outage. The application team sees no request. The automation owner reruns the job and gets a green build. Nothing was diagnosed.
The fix is not “more retries.” It is to model the browser journey as a sequence of observable stages and preserve the first useful error from each run.
This tutorial uses Playwright-flavored TypeScript, but the pattern applies to Selenium, Puppeteer, and other browser drivers.
Start with one deterministic journey
Choose a small journey with a stable success condition. For example:
- connect through an authorized proxy route;
- open a public page you are permitted to test;
- confirm one expected element;
- record the final URL and timing;
- close the context.
Run the same journey without a proxy first. If the direct run is unstable, adding a network layer will make the evidence harder to interpret.
Keep the test input explicit rather than reading dozens of ambient environment variables:
type RouteConfig = {
server: string;
username: string;
password: string;
expectedCountry: string;
sessionMode: "sticky" | "rotating";
};
Pass secrets through your runner's protected secret store. Never print the complete proxy URL or credentials in a trace, screenshot, or CI command line.
Trace stages, not one elapsed time
Create a record that can distinguish setup, proxy authentication, navigation, response, and assertion failures.
type Stage =
| "context-created"
| "navigation-started"
| "response-received"
| "assertion-passed";
type RunTrace = {
runId: string;
routeType: string;
country: string;
sessionMode: string;
stages: Array<{ stage: Stage; at: number }>;
status?: number;
finalUrl?: string;
errorClass?: string;
};
Use a monotonic clock for durations. Wall-clock timestamps are still useful for correlation, but they can move when a machine synchronizes its time.
Listen for the main document response rather than treating every failed image as a navigation outage. Capture the resolved URL because redirects can explain a regional mismatch even when the response is successful.
Make session behavior part of the test
Rotation is a policy, not a generic quality setting.
Use a sticky session when a journey depends on cookies, authentication state, a shopping basket, or a consistent regional experience. Changing the exit address halfway through a multi-step flow can trigger security controls or silently restart the session.
Use rotation between complete, independent runs when each observation should begin with fresh network context. Do not rotate between every asset request inside the same page.
Store the chosen policy in the trace. Otherwise a future reviewer cannot tell whether two different exit addresses were intentional or an infrastructure fault.
Retry to test a hypothesis
A retry should answer a specific question:
- retry once on the same route to test a transient connection failure;
- retry once on a second approved route to test route-specific failure;
- do not retry deterministic authentication errors;
- cap the total attempts and preserve the original error.
const retryable = new Set([
"navigation-timeout",
"connection-reset",
"temporary-dns-failure",
]);
if (!retryable.has(trace.errorClass ?? "")) {
throw originalError;
}
Exponential backoff protects both the target and your own infrastructure. A test that succeeds after five invisible retries is still reporting a reliability problem; it should not be indistinguishable from a first-attempt success.
Check the route with a controlled endpoint
Before loading the application under test, use a controlled endpoint to verify authentication, connection time, and the observed exit location. That check should collect no personal information and should never become an excuse to probe unrelated ports.
If you need residential, ISP, datacenter, or mobile routes for an authorized test matrix, XtremeProxy provides selectable network types and session options. The accompanying browser-automation session design guide explains when sticky and rotating behavior fit different workflows.
Keep provider diagnostics separate from the target application assertion. A healthy route does not prove that the application is healthy, and an application error does not prove that the proxy failed.
Budget concurrency from measurements
Browsers load scripts, fonts, images, and telemetry that a simple HTTP client may avoid. Measure a representative run before scheduling thousands of sessions.
Track transferred bytes, median latency, tail latency, error rate, and browser CPU. Increase concurrency gradually. Respect destination rate limits and cache stable reference data instead of downloading it repeatedly.
Preserve ethical boundaries in code
Use authorized pages and accounts. Respect applicable terms, robots guidance, and technical controls. Do not automate CAPTCHA solving or use a proxy to bypass access restrictions. Avoid collecting personal or confidential data, and retain only the evidence needed for debugging.
Put these constraints in the runner: destination allowlists, rate limits, redaction, retention, and an emergency stop are more reliable than a policy document the runtime never reads.
The review checklist
Before escalating a “proxy failure,” confirm that the trace answers these questions:
- Did context creation succeed?
- Did proxy authentication succeed?
- Was the main document request sent?
- Was a response received, and what was its status?
- Did the page redirect?
- Was the expected element absent, late, or hidden?
- Was the same failure reproduced from a second approved route?
Once those answers exist, the network, automation, and application teams can discuss the same evidence. The goal is not to make every run green. It is to make every failure explainable.
Top comments (0)