Hi guys, just sharing a cool webinar that I watched this week about performance tests, but what I thought really interesting is the demo with Taurus and Jmeter.
The performance tests with Taurus look way more readable and simple than when creating on Jmeter.
Hey guys, today I will post about a quick code to set properties in runtime from jmeter variables.
Where you could use this ?
If you have a list after extract with json path extractor and you want to set a property to use in another thread group, this could be useful.
For example, I will get the serials of a list extracted with json path extractor.
– Create a beanshell script with:
//Get the count of the serials
String countSerials = vars.get("serials_matchNr");
// create a for to create a property for each serial variable
//set each property + index with the variable of each serial in the list
Thank you guys ! See you next week 🙂
So for today I will post the code I am using on Jmeter to get a random index from a list. So, if you have a json with several ids, for example, and you want to choose one of them to use on the next request, you need:
1 – Create a post processor to get the id node from your json response request. As you may know when you use this plugin, jmeter creates automatically the list of variables with the prefix you have chosen and the suffix “__index”. You can see how to use this plugin on my previous post.
2 – Create a Beanshell Sample
3 – Get a random index from this list of ids or you could use this method to get the random id directly. I found easiest get the index r at least it was the first thing which came into my mind.
String idSize = vars.get("ids_matchNr");
int max = Integer.parseInt(idSize);
int min = 1;
int idx = min + (int) (Math.random() * ((max - min) + 1));
String id = vars.get("ids_" + Integer.toString(idx));
Thank you guys ! See you next week or before 🙂
Hi guys, today I will post about how to get a value from a json response with Jmeter.
First we need Jmeter with all plugins installed:
brew install jmeter –with-plugins
Let’s use this response for instance. Look that we have a token which is dynamically generated and we need get this value to use in the next request.
"message": "success registering this user",
You can use this site to find the json path and get the expression to use on jmeter:
So, we got the expression: $.data.token and now we can create the json path extractor with a default value (when jmeter doesn’t find the expression), jsonpath and the variable (which will contain the value of the expression). See:
Now, we can use the variable on a header or another request:
As always, feel free to add any comments !
Cheers. See you next week 🙂
This example I am getting json path from an authentication request and use it in another group thread.
Remember install the json plugin for jmeter (If you don’t have), you can do that with homebrew command :
brew install jmeter --with-plugins
- Create a test plan and set the web server and the port:
- Create HTTP Request, use the variables for the server and the password. Put the path of the authentication page, username and the password.
- Create Json Path Extractor and put the path Expression and the variable that you will use. You can test if your path is correct here.
- Create a beanshell Assertion or Post processor and set the property:
- Create a new Thread Group and a HTTP Header Manager and use the same variable you used before:
- Create the Listener > View Result Tree and it’s done, you can run the jmeter and see if it’s getting the token and using in the next thread group
See you guys 🙂
Hi guys !
Today I will post this tutorial of Jmeter about how use dynamic data from a CSV (Excel or other) file, because a follower asked for some Jmeter’s tutorial.
I did the same here and didn’t have any problem. So, if you have any question/suggestion, just write below !
Thank you 🙂
Hello guys, I noticed that there are a lot of people who want learn Jmeter. So, I found other video that helped me to create a Script that opens a page and after does the login and verifies if the my account appears.
This video is a little fast, but I followed with pauses and I did the same example here.
I hope that this video help you too.