You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A question that is being asked more frequently is how does my website or component affect the web browser (chrome)? So what metrics can we bring about from chrome to show the end user?
Suggested Solution (optional)
Fortunately there is CDP API that can perform this action, which is the performance API. It works by:
Calling Performance.enable
Running the some k6 browser APIs
Calling either Performance.getMetrics to retrieve the metrics
// @ts-checkimport{test,chromium}from'@playwright/test';test('nav_to_test.k6.io',async()=>{constbrowser=awaitchromium.launch()constcontext=awaitbrowser.newContext()constpage=awaitcontext.newPage()constclient=awaitpage.context().newCDPSession(page);client.send('Performance.enable');awaitpage.goto('https://test.k6.io',{waitUntil: 'networkidle'});// Requires some interaction to bring about INP and FID Web Vitalsawaitpage.locator('a[href="/news.php"]').click();constresult=awaitclient.send('Performance.getMetrics');console.log(result.metrics);awaitpage.close({runBeforeUnload: true})awaitbrowser.close()});
In Playwright and Puppeteer, there ins't a dedicated API to perform such an action, instead they allow the use of CDPSession which can be used to run raw CDP requests. It's not clear what the security implications are of opening up a CDPSession like this.
The options for us are:
Create a dedicated API to retrieve these performance metrics, basically a wrapper around the Performance CDP API.
Implement CDPSession but only allow some of the API calls (e.g. only the Performance ones) to be made through it until it's clear what security implications it may have.
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered:
Feature Description
A question that is being asked more frequently is how does my website or component affect the web browser (chrome)? So what metrics can we bring about from chrome to show the end user?
Suggested Solution (optional)
Fortunately there is CDP API that can perform this action, which is the performance API. It works by:
Performance.enable
Performance.getMetrics
to retrieve the metricsPerformance.disable
to end it.This will result in the following:
Here's a PW script that can be used to test this:
In Playwright and Puppeteer, there ins't a dedicated API to perform such an action, instead they allow the use of CDPSession which can be used to run raw CDP requests. It's not clear what the security implications are of opening up a CDPSession like this.
The options for us are:
Performance
CDP API.Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: