Rayrun
← Back to Discord Forum

What's the precise method to measure the time it takes for a page to fully load in Playwright?

cherry_picker_01posted in #help-playwright
Open in Discord
cherry_picker_01

For instance, if a user is navigating to a product page, I'd like to determine the duration from the initial click to the moment when all page content has completely loaded.

Thanks

This thread is trying to answer question ""

13 replies
cherry_picker_01

Bumping.

tphillips8117

You can also use CDP to get your performance timings: https://anandhik.medium.com/performance-testing-in-playwright-64cdef431e2e

tphillips8117

Just had to do a bit of googling 🙂

cherry_picker_01

I was thinking about using web performance APIs alongside Playwright, and my plan looked something like this. But it turns out that the navigation API I had in mind is no longer supported. I tried searching for an alternative but came up empty-handed; there doesn't seem to be any documentation on it.

const time = performance.timing;
    return time.loadEventStart - time.navigationStart;
});```
tphillips8117
await page.goto('https://danube-webshop.herokuapp.com')

  const performanceTimingJson = await page.evaluate(() => JSON.stringify(window.performance.timing))
  const performanceTiming = JSON.parse(performanceTimingJson)

  console.log(performanceTiming)

  const startToInteractive = performanceTiming.domInteractive - performanceTiming.navigationStart
  console.log(`Navigation start to DOM interactive: ${startToInteractive}ms`)
tphillips8117

Found a page talking about using the window performance timing

tphillips8117

not sure where window comes from though, this might be one of those awful AI-generated 'articles'

cherry_picker_01

Yep, I've got this page, and the navigationStart is the part that's no longer supported

https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/navigationStart

tphillips8117

😦

cherry_picker_01

Yes, however, it seems that the new API doesn't provide any apparent alternatives for the navigationStart property.

cherry_picker_01

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].