Example Scenario on JMeter Tests

Previously, it was mentioned how to install JMeter, in the first part of this series. In this part of the blog series, an example scenario on JMeter tests will be explained in detailed.

There is an example scenario in following table;

Scenario Name

End to End Test

Participating Actor


Flow Of Events

  1. The client logs in the Trendyol’s system.
  2. Then, the client selects a random product.
  3. The client adds the product in the basket.
  4. The client logs out.

In order to record, we open the JMeter recorder as we explained above and start the recorder. Now we open our browser and can perform the scenario manually. As we can see, when we perform our scenario manually with the recorder open, our actions are recorded in Recording Controller. 

While we are running our scenario, JMeter records all requests made in the background. For example; analytics.google, facebook, yandex , etc. We need to delete these unnecessary requests and again we need to keep only the ones that are necessary in our scenario.

If I give you an advice based on my experience, we should stop the recorder after each step in the scenario while taking the record and extract the relevant requests and then put the requests for each step in a folder and give it the corresponding name like homepage, login, search , etc.


We must do everything  randomly which we can do. So that, we can correctly apply the load we had set before. For example, let’s say we have a step to select a product. If we do not do this step randomly, the application caches this API and if we always make a request to this API. The site calls this request from its memory and no load occurs. So how do we do the random selection? 

JMeter offers us a feature called Post Processors for this process. Whichever API we apply this Post Processors to, JMeter runs the Post Processors immediately after requesting that API.

When we examine the site, where we carried out our project, we see that our URL path has changed after choosing a product. So we should make this path value dynamic. However, we must find this path value firstly on the site. 

JMeter example

To find this value, we have to go to the page with all the products and open the DevTools. We can do right click on the page and click to Inspect for this. When we inspect our site, we saw the path value in the request we recorded. Now we have to reach this value by using CSS selector. 

Trendyol example

For shown, we have to follow this path:


2.trendyol example

As we can see, when we search the above path on the site, we find 24 answers. Now we need to use these 24 results we found here in our script that we wrote with JMeter. For this, we must first run our script and find the service where these 24 answers are returned from the View Result Tree section. In my script, this is 218. 

Since our path is  CSS selector, we change the text in the View Result Tree window to CSS Selector Tester. After selecting our relevant API in the window that opens, we write our css in the selector section and the relevant value in the attribute section. In this case, this is href.

CSS Selector Tester

As you can see, when we inspected the site, 24 identical results were found as we can see. This is how we can check the correctness of the selector we use. Now, it’s time to use the Post Processors we mentioned at the beginning of your article.

We can add a post processor to the service we want to add a post processor to in our script by following this path.

Right click to service  → Add → Post Processors → CSS Selector Extractor

CSS Selector Extractor

The only thing we need to pay attention to here is the field named Match No. If we enter the value 0 here, it will get a random value among the results in the path we give.

Now we need to integrate the value we call randomPro into the API we use when choosing a product. To use the value we extracted, it’s enough to write that value between $ and {…} . 

HTTP Request example scenario

By the way, if there is a login process in our scenario; we must perform the extract thing to use the token. That will be given after login and we must use it dynamically in other APIs. Because that, token will change after every login process.

JSON extractor example scenario

Now we are ready to run our script in Loadium.