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

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?

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

Capturing query duration using selenium & robotframework

I am using Selenium and Robotframework.
I want to:
submit multiple search values sourced from a csv file
capture the search result values and write out to csv file
capture the duration of the query
How do I do step #3?
Should I be looking to use HAR and parse that for the duration, or is there a way for selenium and robotframework to access this value for each query and write out to file?
You can do this with selenium: https://www.lambdatest.com/blog/how-to-measure-page-load-times-with-selenium/
Browsermob proxy (HAR) should help you measure the request time, especially of ajax responses: https://www.tothenew.com/blog/browsermob-proxy-for-webpage-load-testing-using-selenium/
However if you're just hitting one endpoint (with different requests), you probably want to look into a tool like jmeter: https://jmeter.apache.org/usermanual/glossary.html

script to check entire website to figure out if there are any pages which are taking more time to load

Can we have a script which will crawl through the entire website to figure out if there are any pages which are taking more time to load (some pages under a particular category were taking more time to load) in selenium Webdriver or jmeter
For JMeter you can use HTML Link Parser configuration element for this purposes. From the documentation:
Spidering Example
Consider a simple example: let's say you wanted JMeter to "spider" through your site, hitting link after link parsed from the HTML returned from your server (this is not actually the most useful thing to do, but it serves as a good example). You would create a Simple Controller, and add the "HTML Link Parser" to it. Then, create an HTTP Request, and set the domain to ".*", and the path likewise. This will cause your test sample to match with any link found on the returned pages. If you wanted to restrict the spidering to a particular domain, then change the domain value to the one you want. Then, only links to that domain will be followed.
More information on above approach and a couple more options: How to Spider a Site with JMeter - A Tutorial
Remember that JMeter is not a browser hence it doesn't execute JavaScript so your results may not be precise enough as JMeter doesn't measure the time required to actually render the page.

How to check in jmeter if entered fields remain same in the first page after navigating back from nth page

I want to test a page.Where i want to fill up the fields like first name last name etc.and after going two pages further if i come back to the original page by using back navigation ,data entered for first name and last name remains the same.or it is filled up.
In jmeter i want to check the same if data entered for the fields remain same if i navigate back .
How can i achieve this.
I tried gving url directly in the path its not happening since it is not the way.
please help me since i'm new to jmeter.
You need to understand 2 things. How JMeter works and how your application works.
JMeter only captures data that is communicated to server. It does not matter how data is entered from UI. It does not check if data retains in the fields or not. It only records the request that is sent by your application to server-side.
So, if you understand above, you also need to understand how your application sends data to server. Does it sends the request as you move from first page to second. Or does it send (Submit) data on final page.
Either way, JMeter is not a tool to test if your form fields are retaining data in them as you navigate between pages. As mentioned earlier it only monitors data requests/responses.
Selenium seems a better option for your test requirement.
Please read the apache documentation carefully:
JMeter is not a browser. 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 viewed at a time).
First, you have to understand how JMeter works!!! To do the Functional Testing, Selenium would be a good choice.
Thanks

LoadTesting in Jmeter

I wrote test case using selenium webdrive. also i use junit.
Now i want to test that test case for 100 + users.
So i use treads in that application, but i can go up to that much of users because my memory in not enough for that(open 100+ browsers).
So is there a way to test this in Jmeter.
I can't use badboy recording and import it to Jmeter because somehow my application doesn't support it. (the replay doesn't work in badboay).
Please help me to solve this problem.
Thanks
JMeter offers it's own recording solution - HTTP(s) Test Script Recorder. You can record your test case with it and then try to replay.
If you need to check only unauthenticated navigation, like accessing different pages by anonymous user it should work as a charm. However if you test assumes authentication (log in), creating or updating some stuff, etc. you may need to use HTTP Cookie Manager to deal with user authentication and Regular Expression Extractor Post Processor to fetch dynamic values from responses and add them to next request.
There are some more components you may wish to consider adding to make your test look like more realistic:
Add HTTP Header Manager - to set different headers like User-Agent, Accept-Language, etc. - what real browser does
Add HTTP Cache Manager - to simulate browser cache
Make sure that "Retrieve all embedded resources" property of HTTP Sampler is checked - to simulate parsing css, images, scripts, etc.
Make sure that "Use concurrent pool" is enabled and has size from 2 to 5 threads - as browsers download embedded stuff asynchronously in several threads
Make sure that you filter out external domains in "URLs must match" field - you unlikely want to load test Google Analytics or external banners or whatever

jMeter simulate user's progress through site

I'm a newbie to jMeter, so please bear with me.
I've been assigned the task of testing how an e-commerce website responds under load. I've managed to set up basic tests in jMeter that basically just repeatedly visit the home page, but I'd like to simulate something a bit more realistic:
User arrives on home page
User goes to catalogue page
User views product
User adds product to cart
User returns to catalogue, selects another product, adds to cart
User removes first product from cart
User proceeds to checkout
User completes checkout process.
I'm having trouble finding adequate documentation to explain how to do this. I figured out that I need a cookie manager in my test so that the user session will be maintained, but I haven't figured out how to get the user to traverse the site in a realistic use pattern (such as the one described above). Can anyone help out with this, give me some pointers as where to look for good examples, etc?
This should be no problem, record or manually create the necessary steps as HTTP Samplers, then add them into a Runtime Controller for example to execute them iteratively.
The individual steps will be executed in the order they are in the tree and, in case Cookies are used to handle session state, you might need to add the Cookie Manager to the top of the tree which will handle cookie headers for each user.
Add some timers to simulate user's think time and scale up by increasing the number of virtual users in the thread group.
Use some listener like the Aggregate Report to view the response times for every step.
Try to read http://jmeter.apache.org/usermanual/index.html at first.
Also you'll encounter the problem that Jmeter can't process dynamic pages:
http://wiki.apache.org/jmeter/JMeterFAQ#Does_JMeter_process_dynamic_pages_.28e.g._Javascript_and_applets.29
Does JMeter process dynamic pages (e.g. Javascript and applets)?
No. JMeter does not process Javascript or applets embedded in HTML pages.
JMeter can download the relevant resources (some embedded resources are downloaded automatically if the correct options are set), but it does not process the HTML and execute any Javascript functions.
If the page uses Javascript to build up a URL or submit a form, you can use the Proxy Recording facility to create the necessary sampler. If this is not possible, then manual inspection of the code may be needed to determine what the Javascript is doing.