Performance Testing using Playwright

On This Page What is Performance Testing in the Context of Playwright?January 30, 2026 · 16 min read · Tool Comparison

Performance Testing using Playwright

What do you do when all your UI tests are unripened, yet your coating nevertheless feels slow to user?

It & # 8217; s a frustrative situation-and one most squad run into at some point.

In fact, research shows that nearly 39 % of user abandon a site if images or content take too long to load-meaning performance isn & # 8217; t just a technical concern, it & # 8217; s a and business-impact fear.

Yet traditional UI automation rarely highlights these problems. confirm whether things work, but not how fast they work. That & # 8217; s where becomes surprisingly potent. While not a full-scale tool, it yield you deep admittance to browser-level performance signals.

Performance prove using Playwright focuses on capturing real browser-level performance signals during automated UI workflows. It help teams measure how fast page load, render, and respond from an actual user & # 8217; s perspective.

Overview

How Playwright Facilitates Performance Testing:

  • Provides access to browser execution APIs for seafaring and furnish prosody.
  • Supports HAR recording to analyze meshwork latency, payload sizing, and dim endpoints.
  • Integrates with Chrome DevTools Protocol (CDP) for CPU profiling and JS execution perceptiveness.
  • Captures trace files to envision step-by-step execution behavior.
  • Enables ordered examine across browsers, devices, and stable environments.

Key Considerations for Playwright Performance Testing

  • Ensure consistent tryout surroundings (viewport, timezone, CPU, network).
  • Disable brio, dockhand, and transitions to avoid time noise.
  • Mock or stabilize API response for predictable performance prosody.
  • Use proper wait to enamor settled UI province before mensuration.
  • Collect prosody across multiple runs to avoid single-run variableness.
  • Compare results across browsers to catch rendering differences.
  • Avoid running performance exam on overloaded local machine.
  • Store performance baselines and track changes over clip.

This clause research how Playwright fits into execution examination, the metrics you can capture, how to structure performance-focused test, and how to ensure reliable, meaningful results in 2026 and beyond.

What is Performance Testing in the Context of Playwright?

in Playwright is all about measuring how fast your application behaves from a real exploiter & # 8217; s perspective, not how it execute under heavy load or traffic. While Playwright isn & # 8217; t meant for feign thousands of virtual users, it surpass at capturing browser-level execution signal during genuine user flow.

Think of it as reply questions like:

  • How chop-chop perform the page load when a existent browser renders it?
  • How long do API calls direct during navigation?
  • Is the UI responsive when a user interacts with it?
  • What scripts, assets, or part slow the experience down?

Playwright access the browser & # 8217; s built-in performance APIs, network events, and provide timelines to break metrics that directly impact user experience. This includes navigation timings, web waterfalls, CPU usage, JavaScript execution time, and UI rendering hold.

In little, Playwright helps you validate not precisely whether something works-but how efficiently it works when a real user interacts with your app.

Read More:

Key Performance Metrics You Can Capture With Playwright

Playwright gives you access to a extensive orbit of browser-generated execution information, allowing you to realise how your coating behaves during real user interactions. These metrics help you identify bottlenecks in loading, interpreting, network activity, and script execution.

1. Navigation Timings

Playwright can extract detailed timing around each phase of page load, include:

  • DNS lookup
  • TCP/TLS connection
  • Request/response continuance
  • DOMContentLoaded
  • Load case

These metrics show incisively where delays occur during pilotage.

2. Rendering Metrics (Paint & amp; Layout Events)

Using browser execution APIs and CDP, you can mensurate:

  • First Paint (FP)
  • First Contentful Paint (FCP)
  • Largest Contentful Paint (LCP)
  • Layout shifts

These reveal how quickly content becomes visible and stable for users.

3. Network Timing & amp; Payload Metrics

Playwright can track every request and reply, countenance you measure:

  • API response times
  • Resource shipment times (CSS, JS, images)
  • Request/response sizes
  • Slow, failing, or blocked requests

This helps place which network calls slow down page execution.

4. JavaScript Execution Metrics

Through CDP, Playwright gives visibility into:

  • Long project
  • Script evaluation time
  • JavaScript executing blocks
  • CPU usage

These metrics facilitate pinpoint heavy scripts that delay interactivity.

5. HAR (HTTP Archive) Data

Playwright can generate HAR file showing a accomplished network waterfall, helping you diagnose slow assets, redirects, caching issues, and chokepoint in the loading succession.

6. Browser Traces

Trace files reveal:

  • Timeline of page action
  • Snapshots of UI state
  • Network action
  • Script execution flow

Utile for deep performance profile during debug.

Collecting these metric locally is utilitarian, but browser execution can vary widely across devices, OS versions, and. Running Playwright performance tests on supporter you formalise these metrics on real browsers and real devices, ensuring your execution brainstorm reflect what exploiter actually experience in product.

Methods to Perform Performance Testing in Playwright

Playwright doesn & # 8217; t position itself as a dedicated performance/load tool, but it exposes enough hooks into the browser to let you enamor meaningful performance data. Depending on the depth of insight you need, you can mix and match the methods below.

1. Using Browser Performance APIs

Playwright can evaluate code inside the page and read the browser & # 8217; s built-in Performance API, include piloting and resource timings.

// Navigation timing
const navigationEntries = await page.evaluate (() = & gt; {
homecoming performance.getEntriesByType (& # 8216; navigation & # 8217;);
});

// Resource timings (scripts, images, CSS, XHR, etc.)
const resourceEntries = await page.evaluate (() = & gt; {
homecoming performance.getEntriesByType (& # 8216; resource & # 8217;);
});

This is useful for measuring page burden time, DOMContentLoaded, and how long key imagination take to load.

2. Using Chrome DevTools Protocol (CDP) for Deep Metrics (Chromium)

For Chromium-based browser, Playwright can open a CDP (Chrome DevTools Protocol) session to collect low-level performance metrics like CPU usage, JS performance time, and & # 8220; long tasks & # 8221;.

const client = await page.context () .newCDPSession (page);

await client.send (& # 8216; Performance.enable & # 8217;);
const metrics = await client.send (& # 8216; Performance.getMetrics & # 8217;);

console.log (metrics);

CDP is ideal when you need deeper visibility into JavaScript performance, main-thread blocking, or CPU-heavy operations.

3. Recording HAR Files for Network Performance

Playwright can record HAR (HTTP Archive) files at the setting level, capturing a complete network waterfall: timing, redirects, lading size, and status codification.

const context = await browser.newContext ({
recordHar: {way: & # 8216; network.har & # 8217;}
});

const page = await context.newPage ();
await page.goto (& # 8216; https: //example.com & # 8217;);

// HAR is written when the setting is closed
await context.close ();

HAR files are perfect for analyse slow requests, turgid assets, inefficient caching, and overall network behavior.

4. Using Playwright Tracing for Timeline + Visual Insights

Tracing gives you a detailed timeline of each test run, including actions, snap, and network event. While not a & # 8220; measured & # 8221; by itself, it & # 8217; s extremely helpful for investigating slow steps.

const context = await browser.newContext ();

await context.tracing.start ({
screenshots: true,
snapshots: true,
sources: true
});

const page = await context.newPage ();
await page.goto (& # 8216; https: //example.com & # 8217;);

// & # 8230; run your flow & # 8230;

await context.tracing.stop ({path: & # 8216; trace.zip & # 8217;});

You can open the trace later with Playwright & # 8217; s trace viewer to see exactly where clip was spent during navigation and interactions.

5. Instrumenting Custom Performance Marks and Measures

For business-critical flows (e.g., hunt, checkout, add-to-cart), you can use custom-made marks and measures via the Performance API.

await page.evaluate (() = & gt; {
performance.mark (& # 8216; flow-start & # 8217;);
});

// Perform user action (s) you want to quantify
await page.click (& # 8216; button # checkout & # 8217;);

await page.evaluate (() = & gt; {
performance.mark (& # 8216; flow-end & # 8217;);
performance.measure (& # 8216; checkout-flow & # 8217;, & # 8216; flow-start & # 8217;, & # 8216; flow-end & # 8217;);
});

const measures = await page.evaluate (() = & gt; {
return performance.getEntriesByName (& # 8216; checkout-flow & # 8217;);
});

console.log (measures);

This lets you precisely mensurate how long specific user journeys take, not merely foliate loads.

Read More:

Step-by-Step Setup for Performance Testing

To get reliable and quotable performance results with Playwright, you need a stable and the right configuration.

The measure below ascertain that the metrics you collect are reproducible, meaningful, and adjust with how existent browsers carry.

1. Install Playwright and the Test Runner

Use the recommended initializer:

npm init playwright @ latest

This establish:

  • Playwright Test
  • Browser binaries (Chromium, Firefox, WebKit)
  • Recommended folder construction

2. Configure a Consistent Test Environment

Create or update your playwright.config.ts to define stable browser conditions:

use: {
viewport: {width: 1280, height: 720},
deviceScaleFactor: 1,
timezoneId: & # 8216; UTC & # 8217;,
colorScheme: & # 8216; light-colored & # 8217;,
javaScriptEnabled: true,
ignoreHTTPSErrors: true,
}

This ensures deterministic conditions, since fluctuation in viewport, timezone, or render background can significantly impact performance metrics.

3. Disable Animations and Transitions

Animations cause fluctuations in paint/render timings. Disable them globally:

await page.addStyleTag ({
content: `
* {
transition: none! crucial;
animation: none! crucial;
}
`
});

This ensures paint timestamps are stable across runs.

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

4. Enable HAR Recording (Network Waterfall)

To capture detailed network timings:

const context = await browser.newContext ({
recordHar: {path: & # 8216; network.har & # 8217;}
});

The HAR file is saved when context closes.

5. Enable Tracing for End-to-End Performance Visualization

Playwright line furnish UI snapshots + a timeline of events:

await context.tracing.start ({
screenshots: true,
snapshots: true,
sources: true
});

After the test:

await context.tracing.stop ({path: & # 8216; trace.zip & # 8217;});

6. Enable CDP for Deep Performance Metrics (Chromium Only)

For CPU utilization, JS execution clip, and long-task detection:

const client = await page.context () .newCDPSession (page);
await client.send (& # 8216; Performance.enable & # 8217;);

7. Extract Performance API Metrics

Capture browser-native metrics:

const navTiming = await page.evaluate (() = & gt;
performance.getEntriesByType (& # 8216; navigation & # 8217;)
);

Collect resource timing similarly:

const resourcefulness = await page.evaluate (() = & gt;
performance.getEntriesByType (& # 8216; resource & # 8217;)
);

8. Run Tests in a Stable Environment

Always run execution tests:

  • In headless mode
  • On dedicated CI runners or consistent local machines

Example:

npx playwright trial & # 8211; headed=false

This cut disturbance from OS rendering or UI overhead.

9. Store and Track Performance Baselines

Use logs, JSON export, or your CI system to track changes over time.

Example expectation:

await (navTiming [0] .domComplete) .toBeLessThan (3000);

This helps detect regressions early.

Read More:

Writing Your 1st Performance Test

Once your environment is stable, you can start writing performance-focused exam that quantify how fast your application oodles and responds.

The idea is simple: run a real user flow in the browser, capture metrics, and assert against performance expectations.

1. Measure Canonic Page Load Time

A quick way to detect regressions is to clip page.goto ().

test (& # 8216; page loads under 3s & # 8217;, async ({page}) = & gt; {
const start = Date.now ();
await page.goto (& # 8216; https: //example.com & # 8217;, {waitUntil: & # 8216; load & # 8217;});
expect (Date.now () & # 8211; start) .toBeLessThan (3000);
});

2. Capture Navigation Timing Metrics

Use the Performance API for accurate browser-generated timings.

tryout (& # 8216; sailing timing & # 8217;, async ({page}) = & gt; {
await page.goto (& # 8216; https: //example.com & # 8217;);

const datum = await page.evaluate (() = & gt; {
const n = performance.getEntriesByType (& # 8216; navigation & # 8217;) [0];
return {
dcl: n.domContentLoadedEventEnd & # 8211; n.startTime,
payload: n.loadEventEnd & # 8211; n.startTime
};
});

wait (data.dcl) .toBeLessThan (2000);
expect (data.load) .toBeLessThan (3000);
});

3. Measure a Specific User Flow

Custom marks let you time real interactions like search, add-to-cart, or checkout.

test (& # 8216; hunting stream under 1.5s & # 8217;, async ({page}) = & gt; {
await page.goto (& # 8216; https: //example.com & # 8217;);

const duration = await page.evaluate (async () = & gt; {
performance.mark (& # 8216; start & # 8217;);
// JS inside evaluate won & # 8217; t see Playwright actions,
// so marks only wrap DOM result.
homecoming null;
});

await page.fill (& # 8216; # lookup & # 8217;, & # 8216; playwright & # 8217;);
await page.click (& # 8216; # btn & # 8217;);
await page.waitForSelector (& # 8216; .results & # 8217;);

const t = await page.evaluate (() = & gt; {
performance.mark (& # 8216; end & # 8217;);
performance.measure (& # 8216; flow & # 8217;, & # 8216; start & # 8217;, & # 8216; end & # 8217;);
return performance.getEntriesByName (& # 8216; feed & # 8217;) [0] .duration;
});

await (t) .toBeLessThan (1500);
});

4. Collect Deep Metrics via CDP (Chromium Only)

For CPU/JS-level profiling:

test (& # 8216; CDP metrics & # 8217;, async ({page, browserName}) = & gt; {
if (browserName! == & # 8216; chromium & # 8217;) test.skip ();
const cdp = await page.context () .newCDPSession (page);
await cdp.send (& # 8216; Performance.enable & # 8217;);
await page.goto (& # 8216; https: //example.com & # 8217;);
console.log (await cdp.send (& # 8216; Performance.getMetrics & # 8217;));
});

Read More:

Analyzing Performance Results

Once your tests depart producing prosody, analyzing them correctly is essential to identifying bottlenecks and spotting regression. Focus on these key areas:

1. Compare Against Baselines

Establish expected performance door (e.g., max load time, DCL, flow duration) and compare each test run against them.

  • Identify when metrics exceed baseline.
  • Treat consistent threshold violations as regression.

2. Look for Trends, Not Spikes

Performance is inherently noisy, so rely on patterns.

  • Monitor changes across multiple trial runs.
  • Track variance and sudden gain in clock values.
  • Investigate any gradual up trend.

3. Use Logs to Find the Slow Point

Your test logs reveal which milestone is slow:

  • High DOMContentLoaded↠’ heavy scripts or parsing delays.
  • Eminent load-event time↠’ large assets or third-party scripts.
  • Slow usance flow continuance↠’ UI logic, API name, or rendering topic.

4. Visualize Metrics Over Time

Storing results in CI or performance dashboards aid you spot regressions betimes.

5. Correlate with Real User Data

Semisynthetic tests show potential issues, but validate them using:

  • Core Web Vitals (LCP, FID, CLS)

If synthetic and real-user metric differ, review differences in mesh, device, and environment settings.

6. Identify Root Causes

Once a slowdown is confirmed:

  • Check CPU/JS cost via CDP or DevTools.
  • Inspect API latency for backend delays.
  • Optimize heavy picture, fonts, or scripts.
  • Profile DOM update for inefficient rendering.

Analyzing resolution this way aid you prioritize pickle that deliver the highest execution impact.

Read More:

Integrating Playwright Performance Tests Into CI/CD

Once your performance trial are stable topically, the future step is to run them mechanically on every change. Integrating them into your turns execution from a one-off activity into a continuous quality gate.

1. Separate Performance Tests From Functional Tests

Keep execution tests logically isolated so they don & # 8217; t slow down every single run.

  • Use a naming normal or tag (e.g., @ perf) on performance tests.
  • Run them in a separate job or workflow from your veritable UI tests.

2. Add a Dedicated Performance Stage in CI

Create a specific point (or job) in your CI pipeline that runs test: perf.

Typical form:

  • On every PR: run a small-scale, fast subset of performance tests (critical flows only).
  • Nightly or on main branch: run the full performance suite with more scenario.

Key checks:

  • The job failsif any performance averment (e.g., load clip, flow duration) is overstep.
  • The job publishes artifacts(logs/JSON) to dog prosody over time.

3. Use Stable, Reproducible Test Environments

Performance numbers are only meaningful if the surround is consistent.

  • Use the same Playwright adaptation, browser version, and OS image (e.g., Docker).
  • Fix CPU/memory resources where possible.
  • Configure deterministic settings in Playwright config (viewport, timezone, locale, etc.).
  • Run against a stable test environment (not a noisy shared dev server).

If you & # 8217; re using a cloud grid like BrowserStack Automate, run execution tests onfixed device/OS/browser combinationsand keep those configs versioned in your repo.

4. Export and Store Metrics From Each Run

Don & # 8217; t rely only on console logs-export metric in a machine-readable format.

  • Write timing value (page load, DCL, custom flow durations) into JSON or JUnit-style reports.
  • Upload them as CI artifacts or advertise them to an observability tool
  • Track percentiles (P50, P75, P95) across tally, not merely individual numbers.

This let you to visualize trends and detect slow impetus over days/weeks.

5. Define Clear Failure Criteria and Alerts

Make execution a first-class & # 8220; quality gate & # 8221; in the line.

  • Encode thresholds directly in tryout (e.g., expect (continuance) .toBeLessThan (1500)), or
  • Read thresholds from environs variables so you can adjust them per environment/branch.

When door are breached:

  • The CI job fails.
  • Developers get notified (Slack, email, PR status check).

That way, performance fixation are catch early-just like failing unit or UI tests-and become component of normal development workflow instead of a one-time exercise.

Read More:

Making Performance Testing Reliable

Performance trial are only worthful when their results are ordered and repeatable. To reduce noise and ensure trustworthy prosody, focus on stabilizing the environment and standardizing how tests run.

1. Control the Test Environment

  • Use coherent CI runners, hardware, and Docker images.
  • Pin Playwright and browser versions.

This eliminates variability get by dissent machine performance or browser engine updates.

2. Standardize Browser Settings

  • Fix viewport, timezone, locale, and user agent in the Playwright config.
  • Disable unnecessary living or UI noise.

Uniform browser weather produce more stable timing values across footrace.

3. Stabilize Network and Test Data

  • Apply the same network throttling profile for every run.
  • Use predictable tryout data and stable backend environs.

Consistent meshwork and data province prevent sudden capitulum caused by external ingredient.

4. Warm-Up Before Measuring

  • Run a warm-up navigation or API cry before the actual measurement.
  • Decide whether your tryout represent & # 8220; cold & # 8221; or & # 8220; warm & # 8221; lots and joystick to it.

This avoids false slowdowns caused by first-load cache doings.

5. Use Multiple Runs and Median Values

  • Run critical tryout several times and use average or P90 timings.
  • Set doorway with pocket-size permissiveness margins (e.g., ±10-15 %).

This reduces flakiness and makes your alerts more true.

6. Make Failures Easy to Diagnose

  • Log all compile timings and environment detail.
  • Export metrics (JSON/artifacts) for slew in CI splasher.

Good helps rapidly identify whether a slowdown is real or environmental.

Read More:

When Playwright Should Not Be Used for Performance Testing

Playwright is powerful for lightweight browser performance checks, but it & # 8217; s not suited for every performance scenario. Avoid habituate it in the following cases:

  • High- or :Playwright can not model yard of concurrent users because each browser instance is resource-heavy.
  • Backend or:Playwright measures frontend timings only and can not accurately benchmark API throughput or backend latency. Use dedicated API load-testing creature.
  • Deep Frontend Profiling:It can not give fire graphs, JS execution breakdowns, or remembering profiles.
  • Real-User Experience (RUM) Measurement:Playwright provides synthetic results, not real-user datum across devices, networks, or region.
  • Highly Variable Multi-Step User Journeys:Flows with unstable DOM states or discrepant data introduce too much noise for reliable resultant. Synthetic tools with controlled test pages work better here.
  • Testing on Low-End or Mobile Hardware:Playwright can not accurately mimic low-power CPU or existent mobile gimmick constraints. Use real-device test solution for device-level performance check.

Scale Your Playwright Performance Tests with BrowserStack Automate

BrowserStack Automate provides a stable, cloud-based environment that makes it easier to run Playwright performance checks consistently across different browsers and devices.

  • Run on Real Browsers and Devices:You can run your Playwright tests on real desktop and mobile environments, giving you performance perceptiveness that closely reflect actual user weather.
  • Use Clean and Consistent Test Environments:Each examination lead on an isolated, pre-configured browser and OS combination, reduce variability and facilitate your execution metrics rest consistent across builds.
  • Scale Test Execution with Parallel Runs:BrowserStack Automate supports broad parallelization, countenance you to execute multiple Playwright exam at once and keep execution checks fast enough for CI workflows.
  • Access Detailed Session Logs and Network Data:Every session include videos, console logs, and network logs, helping you pinpoint slow resources, heavy scripts, and bottlenecks within key user flows.
  • Integrate Seamlessly with:Automate works with popular CI systems like GitHub Actions,,, and, enabling you to run performance checks automatically on pull requests or deployments.

Talk to an Expert

Conclusion

Performance testing with Playwright gives team a pragmatic, code-friendly way to mensurate how fast their coating loads and responds during real exploiter flows. By capturing browser-level metrics, instrumenting custom interactions, and integrating test into, you can detect fixation early-long before they reach production.

For execution results to be meaningful, they must be consistent. Stabilizing your environment, standardizing browser background, and utilize quotable data figure guarantee your metrics ruminate real issue, not noise.

And when you & # 8217; re ready to scale, platforms like BrowserStack Automate help you run Playwright exam across real browser and devices, making your execution checks more reliable and production-aligned.

In the end, Playwright doesn & # 8217; t replace full-scale load testing, but it occupy a critical gap by bringing lightweight, developer-friendly performance validation directly into your testing workflow. With the right frame-up and tooling, you can build a fast, reactive application-and proceed it that way with every release.

Useful Resources for Playwright

Tool Comparisons:

Tags
7,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free