Why "page.goto()" is slowing down your Playwright tests in 2026

On This Page Understanding page.goto () in PlaywrightJanuary 21, 2026 · 15 min read · Tool Comparison

Why & # 8220; page.goto () & # 8221; is slowing down your Playwright tests in 2026

The page.goto () method in is a fundamental function that allows exam to lade a specified URL and waiting for the page to reach a specific state before the test continues.

Overview

page.goto () in Playwright is essential for navigating between pages in automated tests, but it can sometimes get slowdowns, impacting test performance.

Introductory Usage:

  • Navigate to a URL:await page.goto (url);
  • Customize Navigation Waits:Use waitUntil to control when the navigation is considered complete (e.g., & # 8220; load & # 8221;, & # 8220; domcontentloaded & # 8221;, & # 8220; networkidle & # 8221;).
  • Set Navigation Timeout:await page.goto (url, {timeout: 30000}); & # 8211; sets the timeout for navigation.
  • Control Browser Context:Can be use within specific browser circumstance for more separated trial.

Common Reasons for page.goto () Slowdowns:

  • Heavy Pages:Large resources (images, scripts) delay load clip.
  • Waiting for All Resources:Default waitUntil: & # 8220; load & # 8221; waits for every resource (stylesheets, iframes) to load, which can be unnecessary.
  • Slow Network/Backend:Slow server responses or network conditions can increase payload multiplication.
  • Non‑essential Resources:Third‑party scripts (ads, analytics) can cause unnecessary wait.
  • Misconfigured waitUntil:Using & # 8220; networkidle & # 8221; or & # 8220; load & # 8221; when only partial page readiness is required leads to longer waits.
  • Test Environment Issues:CI setups, cold browser session, or circumscribed resources may exacerbate slowdowns.

This article explores the internal workings of page.goto (), common cause of slowdowns, and hard-nosed strategy to speed it up, helping you optimise test execution in 2026.

Understanding page.goto () in Playwright

The page.goto () method is a core function in Playwright used to navigate to a condition URL within a browser circumstance during. When called, it point the browser to laden the page and, by nonremittal, waits until the entire page, including all dependent resource such as stylesheets, ikon, scripts, and iframes, is fully loaded and the consignment event is fired.

This comprehensive wait ensures the page is altogether ready for any interactions or assertions that follow in the examination hand. However, this nonpayment behavior can sometimes lead to slower test execution times, especially on resource-heavy pages.

Understanding how page.goto () manages pilotage and loading help in optimizing test performance efficaciously.

How page.goto () act in Playwright

page.goto () is typically one of the initiatory actions in a test, as it open the page or application you want to interact with.

Here & # 8217; s a deeper expression into how page.goto () work:

1. Navigates to a URL:The master role of page.goto () is to navigate to the provided URL. For instance:

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

2. Waits for the page to load:By default, page.goto () will wait until the page shipment case is trigger. This means Playwright will wait for the browser to full lade all resources before continuing to the next step in the test.

3. Customizable Wait Mechanism:Playwright provides a waitUntil selection that countenance you to control what case or state should trip the next action. You can specify different state for navigation, such as:

  • & # 8220; load & # 8221;:Waits for the full page to laden, including all resourcefulness (default behavior).
  • & # 8220; domcontentloaded & # 8221;:Waits for the DOM to be full parsed, but without waiting for persona, styles, and scripts to lading.
  • & # 8220; networkidle & # 8221;:Waits until there are no more than 2 network connections for at least 500 ms. This is useful for SPAs but may be overkill in traditional page test.
  • & # 8220; commit & # 8221;:Waits until the navigation is committed, meaning the URL has changed, but doesn & # 8217; t wait for the full load.

Example:

await page.goto (& # 8216; https: //example.com & # 8217;, {waitUntil: & # 8216; domcontentloaded & # 8217;});

4. Timeout Handling:page.goto () also supports a timeout parameter that allows you to set a maximum amount of time to look for the page to load. If the page doesn & # 8217; t cargo within this time, a timeout error is thrown. This is especially useful in forbid tests from hanging indefinitely due to network or application topic.

await page.goto (& # 8216; https: //example.com & # 8217;, {timeout: 30000}); // 30 seconds timeout

5. Browser Context:If you are running multiple tests, page.goto () can be expend within different browser contexts or pages. This allows for isolated tests where each test runs in a clean session, ensuring that no state is shared between exam.

Mutual Reasons for page.goto () Slowdowns

Respective element can lend to slowdowns when using page.goto () in Playwright examination. Understanding these reasons can assist you identify and purpose execution bottlenecks in your tryout. Here are the most common culprits:

Heavy Pages with Multiple Resources

Web pages today often contain numerous resources like images, book, stylesheets, and third‑party services (ads, analytics, etc.). By default, Playwright waits for all of these resourcefulness to charge when using page.goto ().

Large or resource‑intensive pages can cause significant delays as Playwright wait for these resources to finish loading.

Using waitUntil: & # 8221; load & # 8221;

The default waitUntil: & # 8220; load & # 8221; causes Playwright to await until the full page and all resources (images, scripts, styles, etc.) are fully loaded.

For many tryout, waiting for the integral page to load is unnecessary and can lead to wait. Opting for light-colored wait options like & # 8220; domcontentloaded & # 8221; can importantly reduce the wait time.

Third Party Resources

External resourcefulness such as third & # 8217; # 145; party JavaScript (analytics, societal media gizmo, ads) can slow down page load time, as they often introduce additional network postulation or have variable response times. Playwright waits for all these imagination to charge unless explicitly instructed not to.

Network Conditions and Backend Latency

Slow network connectedness, either due to local setup (like throttle) or backend delays (slow API responses, database calls), can cause page.goto () to take longer to complete.

The networkidle pick, while useful for some applications, can also introduce delays if net requests continue to be made in the background.

Misconfigured waitUntil Options

Using & # 8220; networkidle & # 8221; or & # 8220; load & # 8221; when it & # 8217; s not necessary can result in unnecessarily long waits. For instance, Playwright will wait for baseless network connecter or total page loads, even if your exam simply needs the DOM to be ready or a specific component of the page load. Adjusting this based on your test requirements can speed up navigation significantly.

Test Environment and CI Constraints

Testing surround, especially in CI/CD pipelines, can add overhead that impacts performance. For instance, bunk tests on virtualized or containerized environments with circumscribed resources (memory, CPU) can slow down navigation.

Additionally, if caching is disabled, browser may need to load resource from scratch each clip, further increasing test times.

Browser State and Caching

If tests are pass in a fresh browser context or on cold browser session (where the cache isn & # 8217; t used), Playwright may take to load everything from scratch for every test, causing hold. On the other manus, if caching is enabled, subsequent navigations may be faster as resource are recover from the hoard alternatively of be downloaded again.

By understanding these common component, you can identify which prospect of your examination or environment may be contributing to slow page.goto () time and take steps to optimize them.

Read More:

Analyzing Your page.goto () Bottlenecks

To identify the causes of slow page.goto () performance in Playwright, it & # 8217; s crucial to appraise multiple factors that may be contributing to delays. Here & # 8217; s how you can analyze and pinpoint the bottlenecks:

1. Measure Navigation Time

Log start and end times around page.goto () to understand how long navigation takes. This helps measure the delay.

const start = Date.now ();
await page.goto (& # 8216; https: //example.com & # 8217;);
const duration = Date.now () & # 8211; start;
console.log (` Navigation took $ {duration} ms `);

Use Playwright Trace Viewer for a detailed breakdown of piloting and resource loading.

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

2. Inspect Network Requests

Monitor network logs to name dim or unnecessary requests (images, third-party script) that could be slow down navigation.

page.on (& # 8216; response & # 8217;, reaction = & gt; {
console.log (` Resource URL: $ {response.url ()} & # 8211; Status: $ {response.status ()} `);
});
await page.goto (& # 8216; https: //example.com & # 8217;);

Block non-critical resources (like ads or trackers) to reduce load times.

await page.route (& # 8216; * * / *. {jpg, png, css, js} & # 8217;, route = & gt; route.abort ());

3. Review waitUntil Settings

Adjust the waitUntil parameter to be more effective. Instead of look for & # 8220; load & # 8221;, use & # 8220; domcontentloaded & # 8221; or & # 8220; commit & # 8221; to cut waiting time for unneeded resources.

await page.goto (& # 8216; https: //example.com & # 8217;, {waitUntil: & # 8216; domcontentloaded & # 8217;});

4. Check for Backend/API Latency

Analyze the backend answer time for APIs or databases that might slow down page load. Inspect network logs to see if any calls are causing delays.

5. Evaluate Test Environment

  • Assess the surroundings & # 8217; s resource limitation, as a constrained environment can slow down page navigation. Ensure that (especially cloud or container apparatus) have sufficient resources.
  • Cold browser sessions (without cache) can slow down the test. Reuse session or browser contexts when possible.

6. Examine JavaScript or DOM Blocking

Identify if heavy executing or rendering issues are delaying page readiness. Tools like Playwright & # 8217; s performance insights can help you find furnish or script bottlenecks.

By analyzing these aspects, you can insulate which component of the process is slowing down page.goto () and take the necessary steps to optimize navigation speed in your Playwright tests.

Read More:

How to Speed Up page.goto () in Playwright Tests

Optimizing page.goto () in Playwright can significantly improve the speed of your tests. Here are respective strategy to hie up navigation:

1. Use a Lighter waitUntil Option

Instead of waiting for the entire page to load with the default waitUntil: & # 8216; load & # 8217;, use & # 8220; domcontentloaded & # 8221; or & # 8220; commit & # 8221;. These options trim postponement clip by only look for the DOM or URL change, not all resources to finish loading.

await page.goto (& # 8216; https: //example.com & # 8217;, {waitUntil: & # 8216; domcontentloaded & # 8217;});

2. Block Non-Essential Resources

Block unneeded resources like images, third-party scripts, or ads that aren & # 8217; t necessitate for your tryout. This can zip up page loading by foreclose these items from laden.

await page.route (& # 8216; * * / *. {jpg, png, css, js} & # 8217;, route = & gt; route.abort ());
await page.goto (& # 8216; https: //example.com & # 8217;);

3. Reuse Browser Contexts

Reuse the same browser context or page across tests to obviate the overhead of reloading resources (like logging in) for each test. This reduces setup time.

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

4. Avoid Over Waiting

Playwright & # 8217; s auto-waiting mechanisms are efficient, so avoid using page.waitForTimeout () or unneeded expressed postponement. This countenance Playwright to automatically proceed when elements are ready.

await page.click (& # 8216; # submit & # 8217;); // Waits for the push to be clickable before clicking

5. Mock or Stub Backend/API Responses

If your tests depend on slow backend responses, mock or intercept API calls to return faster responses, reducing the wait for network requests.

await page.route (& # 8216; https: //api.example.com/ * & # 8217;, route = & gt;
route.fulfill ({
status: 200,
body: JSON.stringify ({data: & # 8216; mocked data & # 8217;}),
})
);
await page.goto (& # 8216; https: //example.com & # 8217;);

6. Optimize Test Environment Resources

Ensure your test environment has decent resources (CPU, memory, bandwidth). Avoid slow network weather unless necessary, and run trial on a machine with adequate resourcefulness to prevent slowdown.

7. Leverage Browser Caching

Reuse cached resourcefulness between tests by preventing cache clearing. This avoids re-downloading assets and speeds up pilotage.

const context = await browser.newContext ({cacheEnabled: true});
const page = await context.newPage ();
await page.goto (& # 8216; https: //example.com & # 8217;);

8. Run Tests in Parallel

help to reduce total trial suite runtime. Playwright supports parallel test executing, allowing multiple tests to run at erst, zip up overall performance.

9. Use Unrelenting Storage for Sessions

Persist cookie or local storage across examination to avoid re-logging in or resetting sessions, which can save time and speed up pilotage.

const cookies = await context.cookies ();
await page.context () .addCookies (cookies); // Reuse cookies for subsequent tests

10. Continuously Monitor and Optimize Performance

Regularly track navigation times and execution. Use Playwright & # 8217; s trace and logging to place lag and optimize tryout accordingly.

Read More:

Best Practices for Faster Navigation in Playwright

To accelerate up navigation in your Playwright exam, follow these best practices:

  • Optimize waitUntil Settings:Use & # 8220; domcontentloaded & # 8221; or & # 8220; commit & # 8221; instead of the default & # 8220; load & # 8221; to hasten up navigation by waiting only for the DOM or URL change, not all imagination to cease loading.
  • Block Unnecessary Resources:Block images, CSS files, and third-party scripts (ads, analytics) that aren & # 8217; t involve for your examination to reduce page cargo clip.
  • Use Browser Contexts and Page Reuse:Reuse browser contexts or pages across tests to forefend spare resource loading (e.g., login states or session data), speed up test execution.
  • Leverage Browser Caching:Enable caching between tests to forestall reload the same resources like images and hand, saving clip.
  • Use Persistent Sessions for Authentication:Persist cookie or local depot to maintain authentication states across trial, avoiding restate login steps and saving time.
  • Minimize Explicit Waits:Rely on Playwright & # 8217; s auto-waiting features to mechanically await for element to be ready, instead of using arbitrary waitForTimeout () calls.
  • Use Mocking for Slow Network Calls:Mock or stub obtuse backend API responses to eliminate delays caused by net requests, hasten up tryout that don & # 8217; t require real-time data.
  • Parallelize Tests:Run tests in parallel to cut total test performance time by distributing tests across multiple workers.
  • Avoid Unneeded Navigation:Skip redundant page loads or reprocess already-loaded pages when possible to save time on sailing.
  • Monitor Performance and Continuously Optimize:Regularly track navigation multiplication and use Playwright & # 8217; s tracing tools to place bottlenecks and optimize consequently.

How these Optimizations Impact Your CI/CD Pipeline

Optimizing Playwright tests, specially for fast sailing, can hold a profound impact on the execution and efficiency of your CI/CD pipeline. Here & # 8217; s how:

1. Faster Feedback Loops

  • Agile test execution: By understate waits, reusing browser circumstance, and blocking unnecessary resource, tests run faster, leading to quicker feedback.
  • Former issue detection: Developers can identify and address issues quicker, ensuring that bugs are get early in the growing summons.

2. Reduced Test Suite Runtime

  • Efficiency gains: Reducing the time spent on page.goto () and former resource-heavy operation will drastically cut down overall test rooms runtime.
  • Lower resource intake: Shorter tests use fewer resources (CPU, memory, bandwidth), which is particularly important in cloud-based CI environments where you incur costs for clip and resources.

3. Improved Scalability

  • Handling larger test suites: Optimizations like parallelize tests and caching imagination allow your test suite to scale efficiently as your application grows.
  • Increased test capacity: Faster tests mean more tests can be run within the same clip window, ensuring that new lineament and changes are thoroughly tested without stay the line.

4. Increased Stability and Reliability

  • Reduced flakiness: Optimizing the network and resource direction reduces dependencies on extraneous factors (e.g., slow backend or third-party services), leading to more consistent and stable tests.
  • More predictable results: With fewer false negatives (tests failing due to network delays or third-party service matter), the results are more reliable, providing developer with accurate feedback.

5. Cost-Efficiency

  • Lower infrastructure costs: By reducing trial runtime and optimize resource use, your CI/CD pipeline go more cost-effective. This is peculiarly worthful in cloud-based CI service where you pay for compute time.
  • Faster releases: Optimizations trim the bottleneck that slow tests can create in the pipeline, leading to faster delivery of new features and bug fixes.

6. Increased Developer Velocity

  • Faster deployment: With speedy test executing, the time occupy from codification commit to deployment is shortened, speed the overall growth cycle.
  • More frequent releases: Continuous testing with optimized navigation permit for more frequent, authentic release, check that new features or fixes are deployed quicker.

Read More:

Boost Playwright Test Speed and Reliability with BrowserStack Automate

Integrating Playwright with enhances your trial speed, scalability, and reliability. By leveraging BrowserStack & # 8217; s cloud infrastructure, you can run tests across multiple browsers, devices, and OS combinations simultaneously, drastically cut test executing time.

  • Parallel Test Execution: Run Playwright quiz concurrently on multiple browsers and devices to speed up overall test clip.
  • Cross-Browser and Real Device Coverage: Test your application on real browser and physical device, see consistent performance across all environments.
  • Cloud-Based Testing: Eliminate local resource limitations and run tests in a stable, high-performance cloud environment.
  • Seamless CI/CD Integration: Easily desegregate with popular CI/CD tool, in your pipeline for faster feedback.
  • Rich Test Insights: Gain valuable insights with video recording, logarithm, and screenshots to debug and optimize your tests.
  • Scalability: Easily scale your testing as your trial rooms grows, without worrying about managing substructure.

By offloading testing to the cloud, BrowserStack allows for faster, more reliable Playwright tests, improving both your test coverage and efficiency.

Talk to Expert

Conclusion

Optimizing page.goto () and mix Playwright with tools like BrowserStack Automate can significantly enhance the velocity, reliability, and scalability of your automated examination. By fine-tuning navigation, leveraging cloud infrastructure, and running tests across real browser and devices, you can ensure quicker feedback, more consistent results, and wide coverage.

These optimisation not simply trim the overall test suite runtime but also improve the stability of your CI/CD grapevine, let for faster releases and higher-quality software.

By adopting these strategies, you can streamline your testing procedure, catch issue earlier, and maintain a robust, efficient testing workflow, finally boosting the performance of your covering and ontogenesis round.

Useful Resources for Playwright

Tool Comparisons:

Tags

On This Page

7,000+ Views

# Ask-and-Contributeabout this theme 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