Client-side automation using PageSpeed Insights - how to transmit results like <URL>_<metric> into Summary(/Aggregate) Report in JMeter?

Viewed 70

I'm thinking on solution to automate client-side using Lighthouse or PageSpeed Insights in JMeter.

With PageSpeed Insights, using requests like

https://pagespeed.web.dev/report?url=%2F&form_factor=mobile

https://pagespeed.web.dev/report?url=%2F&form_factor=desktop

it is possible to get web-page which contains client-side metrics and parse out their values to variables:

URL_First Contentful Paint (FCP)

URL_First Input Delay (FID)

URL_Largest Contentful Paint (LCP)

URL_Cumulative Layout Shift (CLS)

URL_Speed Index

URL_Time to Interactive

URL_Total Blocking Time

...

i.e. URL_metric - as variable name, where both URL and metric could change.

The question is, if I want to see the results statistics in JMeter "Summary Report" or "Aggregate Report" view for each combination of URL and metric, what is the best way to pass these variables names (URL_metric) as Label in JMeter?

2 Answers

You could dump the saved values to a file in usual JMeter output format (JTL):

{timestamp},{duration},{sample_name},200,OK,thread_group_name 1-1,text,true,,0,0,20,65,null,0,0,0\n

Curly brackets denote placeholders.

You already have durations and sample names, timestamps do not matter in your case since you only wish to have aggregated results.

After saving the data to a file you could open it with Summary Report or Aggregate Report.

In order to get client-side metrics you will need a real browser, as per JMeter project main page:

JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

So in order to get client-side metrics from JMeter you need to kick off a real browser, for example take a look at WebDriver Sampler which provides JMeter integration with Selenium browser automation framework, check out Mixing Selenium Into Your Load Scenario for more details.

Once you have the metrics you can store them into JMeter's Sample Variables and plot them in custom charts of the HTML Reporting Dashboard

Related