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, 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.
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)
Would it be possible to create a K6 wrapper around Playwright and the Chromium Performance API, allowing the generated performance metrics to be integrated into the K6 ecosystem?
This way, instead of developing xk6-browser, K6 could leverage Playwright as the browser test runner and use the Performance API metrics to provide performance insights.
I’m not sure if there are any limitations—just throwing the idea out there. We have a lot of Playwright smoke tests and are still exploring how to replace K6 browser tests with them since K6 browser tests are harder to write and less stable.
If a wrapper is possible, it could enable a better hybrid testing approach: using K6 API tests to generate load on the server while leveraging Playwright smoke tests to capture browser performance metrics.
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, 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.
In Puppeteer there is
page.metrics
.The options for us are:
Performance
CDP API.Already existing or connected issues / PRs (optional)
#4427
The text was updated successfully, but these errors were encountered: