Correlation: Dynamic data handling using Apache JMeter

In this article, We will talk about how to handle dynamic data in JMeter which is  basically Correlation. Correlation is the important aspect of scripting. Proper handling of dynamic data results in building effective test scripts.

What is Correlation and why is it required ?

Correlation is an act of fetching dynamic data from preceding requests/calls and posting it to the subsequent requests/calls. Lets envision an example to find out why we need correlation. Suppose we have recorded a scenario in which user does the following transactions

  • User enters login details and click submit button,
  • Home page opens and user take further actions,
  • And then Logs out of the system.

Soon after recording if you try to run the script, it may even fail for a single user. This might be because of numerous reasons, lets assume that one of the reason might be authentication mechanism implemented. When a user logged into the system, a unique session is created for user and it will be active until the user logs out of the system. Lets imagine, a unique tokenId is dynamically generated up on user login and is passed to the subsequent requests to validate the user actions. So, one cannot just record and playback the requests having these tokenId’s which are unique for every user sessions. Here, we need to correlate the web requests with the dynamic variables (tokenId). And for correlation, we need to use the “Regular Expression Extractor” which makes use of regular expressions or most commonly known as RegEx.

Continue reading Correlation: Dynamic data handling using Apache JMeter


Power Matching: Using Regular Expressions

When i started working with Apache JMeter, the documentation kept referencing something called Regular Expressions. In fact, I knew so little about this space that when a friend referred to Regular Expressions as “RegEx,” I wondered what he was talking about. Slowly i taught them to myself with the help of Wikipedia and a friend of mine. In this article, i will walk you through the basics of regular expression most commonly known as RegEx which plays a pivotal role in handling dynamic data in JMeter.

What are Regular Expressions, anyway?

Regular Expressions are a sequence of symbols and characters expressing a string or pattern to be searched for within a longer piece of text.  Regular Expressions are about “power matching.” Lets say if you want match the set containing the three strings “Handel“, “Händel“, and “Haendel” can be specified by the pattern H(ä|ae?)ndel; we say that this pattern matches each of the three strings. That is power matching using RegEx.

How do i learn about RegEx ?

Ultimately, understanding and writing Regular Expressions (RegEx) is a little bit like getting your first job. You can’t get hired without experience, and you can’t get experience without getting hired. With RegEx, you don’t really  understand them until you use them, and you can’t really use them until you understand them. So you have to learn a little bit, and then use a little bit and get them wrong, and then go back to the book and learn a little bit more. The other problem you will have with RegEx is that each character is easy. Put them all together and you get this:


And that one wasn’t very hard. The more you work with them, the easier they’ll get.So master each step, put a couple together, make some mistakes and get going. Soon you’ll be a RegEx pro.

The Backslash(\)

I always encourage people to start their “RegEx career” by learning the characters, and the best one to start with is the backslash. A backslash is different from all the other characters, as you will see. It provides a bridge between Regular Expressions and plain text. A backslash “escapes” a character. What does “escape” mean? It means that it turns a Regular Expression character into plain text. If that doesn’t make sense to you yet, hold on – I have a few examples coming.

Continue reading Power Matching: Using Regular Expressions