When performance tests are executed, the main focus is on how the application behaves under heavy load. To analyze it, you need to extract data from a web page and create a new request with the retrieved value. Or you just need to parse the response and validate an assertion. To deal with these challenges efficiently, you can use CSS Selectors in your JMeter scripts.
In this article, we’ll go through the basic usage of CSS Selectors in JMeter scripts. If you need more on this topic, please feel free to contact us through our contact us form.
We have an HTTP Sampler which makes a GET request to a landing page e-commerce website. In the main page, products are listed. To make a randomized navigation from the main page, the URL of the new pages needs to be extracted. To do
Extracting Data from Response
ProductLink Extractor looks like the above figure.
In order to make a GET request to a random link from a list, you should enter “0” in Match No.
Making a New Request
By doing so in every run, you will visit a different link.
How to debug CSS Selector
There, you can debug your CSS expression in JMeter.
CSS Selector Tips
Using .list-group>a to reach an element directly.
2 — Non-Absolute Path
Using a white space between tags to locate the element. Use “.” for class and “#” for id.
.list-group .facebook-signin find the login button
3- Starting Text of an Attribute
You can use tag[attribute^=’starting text’] syntax.
Happy Load Testing!