grafana / xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
329 stars 42 forks source link

The web vitals reported by k6 browser, seems to be very different than what is reported by google's pagespeed API #1396

Open RP451 opened 3 weeks ago

RP451 commented 3 weeks ago

Brief summary

I am running the a browser script and the web vital numbers seem to vary significantly from Google’s pagespeed reports. I am not sure at this point if this has something to do with the k6 framework or the implementation in our script.

Example - For the URL - https://freshprints.com), both the LCP is significantly lower than what is reported by pagespeed insights. And on mobile the numbers deviate even more.

xk6-browser version

using the version included in k6/experimental/browser branch

OS

windows 10

Chrome version

using the version included in k6/experimental/browser branch

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Even a basic script like this is throwing wildly different numbers for all core metrics

import { browser } from 'k6/experimental/browser';

export const options = { scenarios: { browser: { executor: 'constant-vus', exec: 'browserTest', vus: 5, duration: '60s', options: { browser: { type: 'chromium', } } } }, };

export async function browserTest() { const page = browser.newPage();

try { await page.goto('https://freshprints.com/home'); page.waitForLoadState(networkidle); } finally { page.close(); } }

Expected behaviour

The numbers reported by k6 browser should match that of Google's pagespeed report or atleast should be within tolerable values

image

Actual behaviour

All the core metrics vary significantly compared to the numbers reported by pagespeed's API.

image

RP451 commented 3 weeks ago

This problem seems to be worse for mobile devices, the difference there is even higher. Not sure if its just because of the throttling on google's report, but adding that to my script doesn't help much. The numbers on mobile from K6's script seem to be almost the same as on desktop

image