JMeter Tips and Tricks – Episode 1

Hi All, In this articles, I’ll write about JMeter’s key features. JMeter is a powerful tool for performance testing. But there are many features which help test engineer enrich their test scenarios. Let’s start!

Case One

We need to simulate a user group who browse some links in an e-commerce website.

Purpose

Browsing scenarios are very hard to maintain as that page changes frequently and you don’t want to record those page every time you execute the test.

Solution

Xpath Extractor and ForEach Controller

We have an HTTP Sampler (Cars) which make a GET request to a page. There are 20 listings on that page. In order to fetch all the different URLs, we need to use XPath Extractor.

XPath Extractor should have a xpath query (//a[@class=’classfiedTitle’]/@href) to fetch URL’s on the page and those links should be stored in a variable (extractedLink). If the list is empty, it will have a default (NO) value.

In order to make a GET request to all the URL’s, we need to use ForEach Controller which works with a set of object. So reference name of the fetched URLS(extractedLink) should be given as input and output.

Then we need to pass this variable name (extractedLink) to the path field of the next HTTP sampler. Preferably you may give the fetched URL’s name to the HTTP Sampler. So we may observe the results easily.

The results are here, our Thread is making GET request to all URLs on that page.

Case Two

We need to simulate a user who browses a content oriented website.

Purpose

When JMeter record a web site, it stores the CSS, jpg, js file that are valid during the recording time. But content oriented web sites like the newspaper, forums etc tends to change their content very frequently. That’s why when you run the test next day, those requested files won’t be valid. They would not be a good fit because the content is already aged. We need to make GET request to new resources.

Solution

We create an HTTP Sampler and make a GET request to the page and enable “Retrieve All Embedded Resources” under the Advanced tab of this sampler.

By this way, our sampler will always make a call to the updated web site. You don’t need to record test cases once again.

Case Three

Our test environment URL is changing or we have many of them.

Purpose

In general, URLs are hardcoded in the scripts, we need to make URL changeable.

Solution

We need to create an HTTP Request Defaults object in our Test Plan to overwrite URLs, port and other configurations stored in HTTP Samplers.

In this example, we overwrite URL, port and protocol config by new values. But most important information to remember is that you should delete those URL, port and protocol info in all HTTP Samplers.

[fusion_widget_area name=”avada-custom-sidebar-performancetestingwidget” title_size=”” title_color=”” background_color=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” /]

Thanks.
Canberk

1 thought on “JMeter Tips and Tricks – Episode 1”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.