Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Automated UI tests can run slowly when they wait longer than necessary, repeat too much browser setup, depend on slow or unpredictable services, or compete for limited CI resources. The right fix depends on where the time goes: measure setup, navigation, application response, UI state changes, assertions, and teardown before changing waits or adding workers.

Find where the test time goes

Start with one slow run and divide its elapsed time into phases. Use framework traces, test logs, and network evidence where available; Playwright’s best practices include trace collection for diagnosing CI failures.

  • Setup and browser launch: fixture creation, test data setup, and starting the browser.
  • Navigation: document loading and any redirects.
  • Application and API response: server work, network requests, and third-party resources.
  • UI transition: JavaScript rendering, hydration, or a state change after navigation.
  • Assertion and teardown: retrying checks, cleanup, and closing resources.

Record the phase durations for representative runs and compare them. The slowest phase is the best place to investigate first. Causes and their relative impact depend on the app and CI environment; there is no universal ideal runtime or worker count.

Replace unnecessary waits with state-based synchronization

Navigation reaching a document readiness state does not guarantee that a JavaScript application has finished rendering the specific state your next action requires. If the test proceeds too early, it can race the UI and become flaky. Selenium describes synchronization with the application as a common browser-automation challenge in its waiting strategies guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Prefer a wait for the condition the test actually needs—such as a button becoming enabled, a result appearing, or a status changing—rather than an arbitrary fixed sleep. Playwright’s actionability checks and retrying assertions wait for relevant conditions; Selenium documents explicit waits. Avoid piling generic waits on top of each other without evidence: broad waits can hide the real synchronization problem while adding delay.

A short fixed sleep can be useful temporarily to test a hypothesis: if it makes a race disappear, synchronization may be involved. Selenium mentions this as a troubleshooting tactic. Do not leave a large sleep in ordinary test code; it makes every run pay the full delay even when the UI is ready sooner. Replace it with a condition tied to the required state.

Keep browser journeys focused

End-to-end tests are valuable for checking meaningful user behavior, but using a browser journey for every setup step can repeat expensive work. Keep browser coverage focused on the user-facing path you need confidence in; use controlled setup or lower-level tests for other work when that preserves the intended coverage.

External pages and resources can change independently of your application and introduce delay or failure. Playwright’s best practices caution against depending on uncontrolled external pages and describe network controls for supplying needed responses. Keep separate integration coverage for cases where real external behavior is what you intend to test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Long spec files may also be worth organizing differently. Cypress recommends splitting very long spec files, but its FAQ says there is no single runtime threshold that prevents crashes: risk depends on the application and available hardware. Splitting files can improve organization or scheduling, but does not by itself prove that the work or total execution time has decreased.

Separate browser and infrastructure overhead from app performance

Time spent launching a browser, waiting for an HTTP server, loading third-party JavaScript or CSS, or passing through automation instrumentation is part of the test run. Where possible, track those costs separately rather than assuming all elapsed time is application execution. Selenium’s performance-testing guidance says WebDriver is generally not advised for performance testing because browser, network, server, third-party, and instrumentation variation can obscure measurements. Cypress also notes that instrumentation adds overhead in its FAQ.

For application-speed questions, use performance-focused tooling and measurements suited to that goal. Functional browser tests answer whether user-facing behavior works; their total duration is not a precise measurement of application performance.

Increase parallelism only when the suite and runners can support it

More workers can reduce wall-clock time when tests are waiting in a queue and the runner has enough CPU, memory, browser capacity, and backend capacity. They can instead add contention when those resources are already saturated. Playwright runs workers as separate processes and lets teams set a worker limit; see its parallelism guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Parallel browser contexts do not make shared backend records safe. Two tests that change the same account, order, or external resource can collide and become flaky. Give tests distinct data and avoid shared state, as Selenium advises in Avoid sharing state. Then tune the worker count using measurements from the actual CI environment.

Choose a fix by the bottleneck it addresses

Observed bottleneck Remedy to consider Trade-off to check
Long fixed delays or races around UI changes Wait for the required UI state with a framework-native wait or retrying assertion. Preserve the behavior being tested; do not replace a meaningful condition with a generic wait.
Repeated setup through a browser Use controlled setup or lower-level tests for setup work, while retaining browser coverage for meaningful user paths. Changing test scope can reduce confidence if the user-facing path is no longer exercised.
Slow server, third-party resource, or browser startup Measure that phase separately and control external responses where appropriate. Keep real integration tests when verifying the external dependency is the purpose.
Tests queued behind other tests Increase workers if runner and backend resources have headroom. More workers require capacity and isolated test data; otherwise contention and collisions can worsen results.
Need to know whether the app itself is fast Use performance-focused measurements rather than inferring speed from functional test duration. Functional browser tests include synchronization and environmental variability.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a clean screenshot of a page as part of a workflow, ScreenshotNeo is a website screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF; the API does not replace a UI test suite or measure application performance.

Example using cURL (replace the target URL as needed):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API details. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up free for 1,000 screenshots a month, with no card required.

What the evidence does—and does not—say

A 2023 TRaf paper reports an 11.1% execution-time reduction for its proposed time-based asynchronous-wait repair method and evaluation: arXiv abstract. That study-specific result is not an expected gain for arbitrary UI suites. The framework guidance cited above does not establish a general benchmark for the fixes in this guide.

Frequently Asked Questions

Can a UI test be slow even when the application is fast?

Yes. Browser startup, test setup, automation instrumentation, network dependencies, and synchronization can all contribute to test duration independently of the app’s own speed.

Should I use a fixed sleep to make a flaky test reliable?

A brief sleep can help test whether timing is involved, but a permanent fixed delay is usually less efficient than waiting for the specific UI state the test needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Will adding workers always make the suite faster?

No. Parallelism helps only when work is queued and the runner and backend have spare capacity; shared test data can also cause collisions.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 2
Bestseller No. 3

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.