This is outstanding!! I am working on designing a Performance Test framework for my Applications APIs. I am done with creating my production ready design within 10 days.... All because of you. I did not refer any other sites or videos.... Your explanation is so simple and powerful... Kudos to you... Thank you Brother.. If my manager appreciates on looking at design... the tribute will go to you.. :-)
sorry to be offtopic but does anyone know a tool to log back into an instagram account..? I was stupid forgot the account password. I would love any tips you can give me!
Nicole Try these steps: 1. Extract the value: Use a Post-Processor (like Regular Expression Extractor) in the first thread group to extract the desired value from the response. Store it in a variable, e.g., ${extractedID}. 2. Promote the variable to a property: Variables are local to thread groups. To make the value accessible globally, convert it to a property using the __setProperty() function: ${__setProperty(propertyName,${extractedID},)} Add this function to a suitable element within the first thread group, such as a BeanShell PostProcessor or a JSR223 PostProcessor. 3. Access the property in the second thread group: Use the __P() function to retrieve the property value: ${__P(propertyName,)} You can use this expression in any request or element within the second thread group. Example: Thread Group 1: Extract userID from a response using Regular Expression Extractor. Use BeanShell PostProcessor: \{\_\_setProperty\(userId,{userID},)} Thread Group 2: Use userID in a request: /users/${__P(userId,)} Additional considerations: Multiple threads: If multiple threads need to use different extracted values, consider alternative approaches like: CSV Data Set Config to store and retrieve values. Inter-Thread Communication Plugin for thread synchronization. Property overwrites: Be cautious as properties can be overwritten by subsequent thread groups. Synchronization: If threads need to access the value in a specific order, use suitable synchronization mechanisms. Remember: Choose the most appropriate method based on your specific use case and data requirements. Thoroughly test your script to ensure values are being passed and used correctly.
Hi Raghav, thanks for your wonderful sessions. Could you give suggestion to implement the following step. I need to pass the json extractor value to the POST request body. Which syntax I should use here?
Hello Raghav, I have a question regarding extracting multiple records with a JSON extractor. Specifically, how can we indicate the match numbers for each record extracted? For instance, if we have variables named User 1 and User 2, can we denote the match numbers as 2;3, or is there another option?" Thanks!
Mohit In JMeter, you can extract multiple values from a JSON response using the JSON Extractor. The "Match No." field in the JSON Extractor allows you to specify which match to use. Here's how you can use it.. 1. Add the JSON Extractor as a child of the HTTP request sampler that returns the JSON response 2. In the "Variable Names" field, enter the names of the variables where the extracted values will be stored. If you're extracting multiple values, you can enter multiple variable names separated by semicolons 3. In the "JSON Path Expressions" field, enter the JSON Path expressions to extract the values from the JSON response. If you're extracting multiple values, you can enter multiple JSON Path expressions separated by semicolons 4. In the "Match No." field, enter the match numbers for each JSON Path expression. If you're extracting multiple values, you can enter multiple match numbers separated by semicolons. For example, if you want to extract the second and third matches, you can enter "2;3" Here's an example configuration: - Variable Names: User1;User2 - JSON Path Expressions: $.user1;$.user2 - Match No.: 2;3 This configuration will store the second match of `$.user1` in `User1` and the third match of `$.user2` in `User2`. If you want to extract all matches, you can enter "-1" in the "Match No." field¹. If you want to extract a random match, you can enter "0" in the "Match No." field Please note that the match numbers are 1-indexed, meaning the first match corresponds to 1, not 0
My json extractor doesn't seem to be working, I am getting an illegal character response code because I am trying to use the variable in the http request path
Hi, this mostly is due to the json path you created . You can try to generate json path using jsonpathfinder.com/ And then if required modify and check here www.freeformatter.com/json-escape.html
Hi Raghav, I have Extracted the Auth Token using Json Extractor into a variable, and I want to use that particular variable into my each API (around 40 APIs)Headers of my test plan. Is there any way to use that Variable one time and my Auth token will work for all the APIs? Thanks in Advance
Hi Amar, for any config element, if you put the requests as child of the element, it will follow that configuration, Else, if here is any need to refer the variable inside the request, then you will have to update the reference in all request for one time
Hello, I have scenario where I have to use the variable extracted (e.guser1} in onother http Request but in another Thread Group. It seems that does not work, works only for different http that are below same Thread Group. Do you have any idea in here? Cheers.
Once you extract the value from json in a variable, You can put this variable value in a property and then it will be available to other threads. See this example - stackoverflow.com/questions/707832/how-do-i-pass-a-variable-from-one-thread-group-to-another-in-jmeter
Hi Ragav, do you have any video on JDBC post Processor. I have number of returned row in response from JDBC request. I want to store that value in different variable and use letter on like you are showing here using Jason extractor. Thank you.
Hi Raghav, i want to generate and use the jwt in other endpoint, but i need to pass more than 1000 dynamic variables in actual HTTP request using CSV data config file , using json extractor I am not able to do it both at a time any suggestions
I have Jmeter tests where I use Bearer token, these tokens expire after some time, so when i try to run a longevity test, the test fails after the tokens expire, how do i regenerate the token just about the expiration time so that the tests do not fail.
Hi Raghav, I am trying to test a OAuth authentication login for a Web App, i can generated the access token, but somehow still getting 400 bad request. even tried to use JSON Extractor to get the token and use in other requests. Can you Advise.
@@RaghavPal Hi Raghav, it was a help but still something seem to be missing. can you please advise is MS AD login authentication used in a web app can be stimulated or not, I mean is there a possibility to do so.
I have used UUID to a variable in the request body of POST request..How to extract that variable generated value from the request body after execution and store it for the sampler request in next thread group?
Varsha To extract the dynamically generated UUID value from the request body in JMeter and use it in a subsequent thread group, follow these steps: 1. Extract the UUID Value: - In your JMeter test plan, add a Regular Expression Extractor or a JSON Extractor to the sampler that generates the UUID. These extractors allow you to capture specific values from the response. - Configure the extractor to capture the UUID value from the response body. Specify the appropriate regular expression or JSON path expression to match the UUID format. - Store the extracted value in a JMeter variable (e.g., `${UUID}`). 2. Pass the Variable to the Next Thread Group: - To pass the extracted UUID value to a subsequent thread group, you have a few options: - User Defined Variables: - Add a User Defined Variables element at the test plan level. - Define a variable (e.g., `UUID`) with the extracted value. - This variable will be accessible across thread groups. - Inter-Thread Communication: - Use the Inter-Thread Communication PreProcessor. - Set the variable in one thread group and retrieve it in another. - Property File: - Write the UUID value to a property file using a BeanShell PostProcessor or a JSR223 PostProcessor. - In the next thread group, read the value from the property file using a BeanShell PreProcessor or a JSR223 PreProcessor. 3. Reference the Variable in the Next Thread Group: - In the subsequent thread group, reference the `${UUID}` variable wherever you need it (e.g., in the request body of another sampler). - JMeter will replace `${UUID}` with the actual value extracted during execution. Remember to adjust the variable names and configurations according to your specific test plan. This approach ensures that the dynamically generated UUID is available for use in subsequent thread groups. Happy testing --
I have a question, I understand your concepts well. this is the scenario. 1) I have to hit POST api, once i hit that responce will be bearer token and after rest of the api's i have to add those token in the header. 2) if i have login api of 100 users, and afterwards i have to hit rest of the apis for each user, everytime when i login the new token will be created, how can i add those tokens to rest of the apis
Sundar Here's how to handle dynamic bearer tokens for multiple users in JMeter: 1. Extract Token from Login Response: - Regular Expression Extractor: Add a Regular Expression Extractor as a Post-Processor to the login request. - Configure Extractor: Set the following properties: - Reference Name: Choose a meaningful name (e.g., `bearer_token`). - Regular Expression: Compose a regular expression to capture the token from the response (e.g., `"access_token": "(.+?)"`). - Template: `$1$` (extracts the first matching group). - Match No.: 1 (assuming the first occurrence of the token). 2. Add Token to Subsequent Requests: - HTTP Header Manager: Add an HTTP Header Manager to each request that requires the token. - Set Header Name and Value: Configure the header name to `Authorization` and the value to `Bearer ${bearer_token}` (using the variable extracted in step 1). 3. Handle Multiple Users: - CSV Data Set Config: Use a CSV Data Set Config to read a CSV file containing user credentials. - Loop Controller: Enclose all login and subsequent requests within a Loop Controller. - Set Loop Count: Set the loop count to 100 (or the number of users in your CSV file). - Variable Names: Ensure variable names in the CSV Data Set Config match those used in the login request. 4. JMeter Thread Groups: - Consider Thread Groups: For better control and performance, consider using multiple Thread Groups, each simulating a specific number of users. Additional Tips: - Debug Sampler: Use the Debug Sampler to inspect variables and ensure token extraction is working correctly. - Think Times: Add appropriate think times to simulate realistic user behavior. - Concurrency: Adjust concurrency settings in Thread Groups to manage load. - Correlation: If token positions vary, use JMeter's correlation features for dynamic extraction.
Hi Raghav , need a help. Below is my json {"numFound":1,"docs":[{"Id":"547259","count":1514380,"price":0.0}]} in Json Path extractor ,while trying JSON Path expressions , its allowing only one value if I try more than One like $..count; $..Id - not working Names of created variables - count; Id
Hi Raghav, I am working on API testing with Jmeter to validate different set of results from JSON. My Scenario is 1. Run API & extract and store variables. (completed as above) 2. COmpare the values (the Json with values A,B,C,D and have to verify B=A+C , and publsih True or False ) How to perform these arithmetic Operations in Jmeter & Say True or False ? Please help. Thank you.
Hi Raghav , i need to make a script like if status code is not 200 then mail should be triggered to me through jmeter . can u please give me an idea how can i implement.
Hi Raghav, thanks for your tutorials. It's been most useful. One small suggetion is that please increase the audio/sound for your tutorials. It is very low and even with 100% volume in the computer it is very low. Tried with different systems and different headsets but its the same. Please look into this.... Regards :-)
Hi Raghav, I need to pass the variable from the json extractor of the 1 request into the body of the 2nd request. (instead in the URL) . Tried the syntax from the video but it didnt work if I use the extracted variable in the request body of the 2nd request. Please let me know, how we can achieve it?
Hi Saurabh, You just need to parameterize the value where you want to use the extracted data and refer it from a user variable. And during executed when you extract the value, update the user variable with it and the next request will refer it from there.
Hi Raghav! I am doing jmeter using api, I am passing huge data through csv file and running my scripts. My scripts run for nearly 3 to 5 hrs. I have some failures where i can verify from tree, assertions, and from failure csv data file reports.....but for failed reports I have to manually verify in postman and check the cause of failure , and for that i need to pass (POST-Request Body) manually. I cannot do it for multiple data's, so I want to extract whole Request Body from jmeter and display in my html report and then when ever i want i can analyse failure request and hit in postman directly. How do I extract Request Body?
Hi Nazneen, have you tried providing a csv file location in teh View Results Tree or other listener in File name section. BTW you should not use View Results Tree listener while doing actual performance test as it is memory consuming listener. Some links that may be helpful www.blazemeter.com/blog/how-to-save-response-data-in-jmeter/ stackoverflow.com/questions/1515689/jmeter-how-to-log-the-full-request-for-a-failed-response
Hi Akash, you can extract data from json as shown in this video and then you can use the variables in any subsequent request, for e.g. if you stored extracted value in a variable called User1, In any future request you can use ${User1} to refer
Hi Dhana, I have not used it, but check this dzone.com/articles/advanced-usage-of-the-json-path-extractor-in-jmete stackoverflow.com/questions/43444277/jmeter-json-path-extractor-conditional-selection
Hi Sayali, I believe you will need to add some scripting for that. I have not tried, can get some help here - stackoverflow.com/questions/30589715/how-to-read-external-json-file-from-jmeter
Hi Raghav, Could you please elaborate why we have to give default value for json extractor when you have used more than one variable and json path expression?
Hi Raghav, Can I use Json extractor to extract all values of Json response into a csv file into different rows and columns? Do you have any video on this?
Hi Saranga, I believe there is no direct way and you will have to add a script sample as a child of json extractor and add the script to write results to csv. This can help stackoverflow.com/questions/35742949/extracting-a-value-from-jmeter-response-and-exporting-it-to-a-csv-file
Hi! I have csv data file with multiple data say 50 or 100....now how do i do json extractor by making use of csv data and then extract data and display in HTML reports.....Plz help me to sort out this issue.
Hi Nazneen, have you tried csv data set config to get data from csv. You can store in variables and use the variables in other elements like JSON extractor
I have to test an API, firstly HTTP request is running and then JSON extractor so it is throwing an error because no value is getting passed, I have kept it as a child. So, how to get the value from Json Extractor and pass it?
Hi Ashita, first make sure you are getting the value to be extracted in the response and after that you can use the JSON extractor as shown in the video. Let me know where exactly you faced the issue. Ensure you create right json path
@@RaghavPal Yes, Raghav..I have taken out the value from the response, verified it using the tool - jsonpath.curiousconcept.com Still, I'm not getting the value, when I am debugging, firstly the request is running and then the JSON extractor. One more thing, JSON has an array.
Sir, I a trying to automate one of the REst API using JMeter using HTTP request but there is a problem coming stating 400 bad request. I provided the username and Password in the HTTP Authentication manager, this does not worked.Could you plz helped me out may be with videos.plz
Hi Anil, 400 is for bad request, So I believe the issue is not with authorization but your request. Try to check all your request parameters, Check for any typo, spaces etc.
Hi Prasad, you will need it when you are doing any API test having JSON response. This can be used for multiple things, e.g. To fetch a value from response and store in a variable to assert it Pass the value to any other subsequent request To validate/assert node count in json etc. I will have new videos to explain some of these.
Hi Raghav, can you please make a video of how to use JSON extractor for combination of POST and PUT API requests having body parameter? It will be very helpful
Thanks Ragnav, great tutorials! I have a question about JSON extraction. What if i need to cycle though values in ${USER1} like ${USER1_1}, ${USER1_2}, etc? I have multiple images, which are to be loaded, if response is not empty, so i call If statement, then extract url of images using JSON Extractor, but after i dont know how to cycle request using those images url's. Maybe you have some advise?
Hi Raghav, How can I fetch the extracted value in JMS Publisher? I don't see the Path option to pass the json extracted variable in JMS Publisher? Any suggestions please?
Hi Raghav - I am able to extract value 'ID' from the 1st Subscriber and fetch it in the 2nd Publisher with the syntax ${variableName} . But not able to fetch the same ${Id} in my 3rd Publisher?? Any Suggestions? I did used ${Id} in my file and jMeter seems to be working fine.. like I see the correct 'ID' in the Response Data for the 3rd Publisher but in general it is not fetching the 'ID' for the 3rd Publisher?
Automation Step by Step - Raghav Pal Hello sir no answer recived on the other commt, sorry for the tje same commt but plz let me know which is best plz sir i need it urgent so i can apply before sept.
Hi Sanket, you can add response assertion or others as per your need, There is a video on assertions, pls check. automationstepbystep.com/online-courses/
Hi Rahgav , When using step by step debugger it's skipping JDBC configuration configuration and because of that validate login request is getting failed .Could you please give some idea to implement this .
Hi Sonia, as per this page github.com/Blazemeter/jmeter-debugger The known limitations of step-by-step debugger is Only one thread group at a time can be debugged (evaluate panel allows to mitigate the limitation)Module Controllers and Include Controllers are not supported Just check if your element falls into any of this
Hi Sriram, This will help - www.testingexcellence.com/jmeter-tutorial-how-to-send-a-json-file-as-request-in-body/ www.blazemeter.com/blog/how-to-use-the-json-plugin-in-jmeter/
Hello.. i mean if I use match no = -1 in json extractor. then it will return an array of variable... if i want to use the extractor variable in next http request..which is inside an array.. then i need a loop... you use specific variable ${User1}...... i did it by using foreach controller... is there any other way?
hi raghav, awesome video. but I have one query suppose in a single variable multiple I'd are stored in case of -1.so which I'd is passed in subsequent request.
Hi Sumit, glad to know it helped. As i explained in the video, if you use -1 in Match No. field, than all the values matching the expression will be stored in variable and the variable name will be updated. E.g. If you have used variable name User and there are 2 values, then 2 variables will be auto-genrated User_1 & User_2 . and you have to pass these variables to any subsequent request.
Chandrima When using the JSON Extractor in JMeter, it's important to ensure that you're using the correct syntax for extracting multiple values. If you want to extract multiple values into different variables, you need to separate the variable names and JSON path expressions with semicolons and provide a default value for each variable. Here's how you can configure the JSON Extractor for multiple variables: 1. Variable Names: Specify the names of the variables you want to create, separated by semicolons. 2. JSON Path Expressions: List the JSON path expressions corresponding to each variable, separated by semicolons. 3. Default Values: Provide default values for each variable, separated by semicolons. Here's an example configuration: - Variable Names: `id;first_name` - JSON Path Expressions: `$..id;$..first_name` - Default Values: `NOT_FOUND;NOT_FOUND` This configuration will create two JMeter variables named `id` and `first_name`, each extracting values from the JSON response based on the provided JSON path expressions. If the JSON path does not find a match, it will assign the value `NOT_FOUND` to the respective variable¹². Make sure that your JSON response structure matches the JSON path expressions you are using. If you continue to face issues, you might want to verify the JSON path expressions with a tool like JSONPath Online Evaluator to ensure they are correct.
Hi Shilpa, in that case you will have to store the extracted value in a property. Some links to help you medium.com/@priyank.it/jmeter-passing-variables-between-threads-a4dc09903b59 www.testingexcellence.com/jmeter-pass-variables-between-thread-groups/
Hi Saddam, I could see XML schema assertion in JMeter, but nothing on JSON schema, you might have to do some custom scripting for this, but do check online thoroughly, i might have missed it.
Thanks for the reply.... I was just checking is there any available option available in JMeter, which i might have missed to explore or unaware of... Yes you are right I need to right custom JSON schema assertion...
I have added 3 HTTP Request, I am getting auth token from the first request and I want to use this for rest 2 request. I used JSON Extractor and getting auth token in the second request, and applied the same thing in the third request but not getting auth token, it gives me an Unauthorized error, can you please help me how I can get it? Thanks in advance!!
Hi Mayur, mostly it might be due to incorrect implementation. To get to the root cause I will need to check your setup and test. Do you have any logs? Also you can use debugger to troubleshoot. - th-cam.com/video/7JI3GD0ifTw/w-d-xo.html
Hi Raghav! Thanks for the tutorials. Also could you please help in how to state a condition while using extractors. for eg: lets say there is a json response which contains an attribute "price" and I want to extract it only when the price is greater that 5.
This is outstanding!! I am working on designing a Performance Test framework for my Applications APIs. I am done with creating my production ready design within 10 days.... All because of you. I did not refer any other sites or videos.... Your explanation is so simple and powerful... Kudos to you... Thank you Brother..
If my manager appreciates on looking at design... the tribute will go to you.. :-)
So happy to know this Deepak, All the best
This guy deserves an Oscar for keeping learn time low and knowledge base high! Please vote!
I am so happy and humbled to see this message. Thanks Phil
sorry to be offtopic but does anyone know a tool to log back into an instagram account..?
I was stupid forgot the account password. I would love any tips you can give me!
Hi Raghav,
Thanks for this tutorial video. I have learned so quickly and easily.
You are most welcome Dimple
Thank you for that video. How can that same extracted id use in another thread group?
Nicole
Try these steps:
1. Extract the value:
Use a Post-Processor (like Regular Expression Extractor) in the first thread group to extract the desired value from the response. Store it in a variable, e.g., ${extractedID}.
2. Promote the variable to a property:
Variables are local to thread groups. To make the value accessible globally, convert it to a property using the __setProperty() function:
${__setProperty(propertyName,${extractedID},)}
Add this function to a suitable element within the first thread group, such as a BeanShell PostProcessor or a JSR223 PostProcessor.
3. Access the property in the second thread group:
Use the __P() function to retrieve the property value:
${__P(propertyName,)}
You can use this expression in any request or element within the second thread group.
Example:
Thread Group 1:
Extract userID from a response using Regular Expression Extractor.
Use BeanShell PostProcessor: \{\_\_setProperty\(userId,{userID},)}
Thread Group 2:
Use userID in a request: /users/${__P(userId,)}
Additional considerations:
Multiple threads: If multiple threads need to use different extracted values, consider alternative approaches like:
CSV Data Set Config to store and retrieve values.
Inter-Thread Communication Plugin for thread synchronization.
Property overwrites: Be cautious as properties can be overwritten by subsequent thread groups.
Synchronization: If threads need to access the value in a specific order, use suitable synchronization mechanisms.
Remember:
Choose the most appropriate method based on your specific use case and data requirements.
Thoroughly test your script to ensure values are being passed and used correctly.
Very nice explanation, Thanks Bro
You are welcome Sriram
Hi Raghav, thanks for your wonderful sessions.
Could you give suggestion to implement the following step.
I need to pass the json extractor value to the POST request body. Which syntax I should use here?
Hi Lakshmi, the syntax and process will remain same as shown for any type of request sampler
Eres el mejor you are the best !!!! Greetings from Colombia
Muchas gracias
Hello Raghav, I have a question regarding extracting multiple records with a JSON extractor. Specifically, how can we indicate the match numbers for each record extracted? For instance, if we have variables named User 1 and User 2, can we denote the match numbers as 2;3, or is there another option?"
Thanks!
Mohit
In JMeter, you can extract multiple values from a JSON response using the JSON Extractor. The "Match No." field in the JSON Extractor allows you to specify which match to use. Here's how you can use it..
1. Add the JSON Extractor as a child of the HTTP request sampler that returns the JSON response
2. In the "Variable Names" field, enter the names of the variables where the extracted values will be stored. If you're extracting multiple values, you can enter multiple variable names separated by semicolons
3. In the "JSON Path Expressions" field, enter the JSON Path expressions to extract the values from the JSON response. If you're extracting multiple values, you can enter multiple JSON Path expressions separated by semicolons
4. In the "Match No." field, enter the match numbers for each JSON Path expression. If you're extracting multiple values, you can enter multiple match numbers separated by semicolons. For example, if you want to extract the second and third matches, you can enter "2;3"
Here's an example configuration:
- Variable Names: User1;User2
- JSON Path Expressions: $.user1;$.user2
- Match No.: 2;3
This configuration will store the second match of `$.user1` in `User1` and the third match of `$.user2` in `User2`.
If you want to extract all matches, you can enter "-1" in the "Match No." field¹. If you want to extract a random match, you can enter "0" in the "Match No." field
Please note that the match numbers are 1-indexed, meaning the first match corresponds to 1, not 0
@@RaghavPalThanks for the reply. 🙂
My json extractor doesn't seem to be working, I am getting an illegal character response code because I am trying to use the variable in the http request path
Hi, this mostly is due to the json path you created . You can try to generate json path using jsonpathfinder.com/
And then if required modify and check here www.freeformatter.com/json-escape.html
@@RaghavPal Thanks, I've got it working now!
Hi Raghav, I have Extracted the Auth Token using Json Extractor into a variable, and I want to use that particular variable into my each API (around 40 APIs)Headers of my test plan. Is there any way to use that Variable one time and my Auth token will work for all the APIs?
Thanks in Advance
Hi Amar, for any config element, if you put the requests as child of the element, it will follow that configuration, Else, if here is any need to refer the variable inside the request, then you will have to update the reference in all request for one time
Hello Pal
I want to enabled my recording generated with Line number, How can I do it, can you please return with answer
I will need to check on this. You can also try checking online
Hello, I have scenario where I have to use the variable extracted (e.guser1} in onother http Request but in another Thread Group. It seems that does not work, works only for different http that are below same Thread Group. Do you have any idea in here? Cheers.
Once you extract the value from json in a variable, You can put this variable value in a property and then it will be available to other threads. See this example - stackoverflow.com/questions/707832/how-do-i-pass-a-variable-from-one-thread-group-to-another-in-jmeter
Hi Ragav, do you have any video on JDBC post Processor. I have number of returned row in response from JDBC request. I want to store that value in different variable and use letter on like you are showing here using Jason extractor. Thank you.
Hi Anita, not as of now, I will try to add on this
@@RaghavPal Thank you
Hi Raghav, i want to generate and use the jwt in other endpoint, but i need to pass more than 1000 dynamic variables in actual HTTP request using CSV data config file , using json extractor I am not able to do it both at a time any suggestions
Hi Fazeel, you will need to store in a variable and refer it where needed, if using csv file, you can use the header as variable
Dude you're a beast, I can't say more...
Thanks for watching Alexis
Great Video.
Thanks for watching Anita
I have Jmeter tests where I use Bearer token, these tokens expire after some time, so when i try to run a longevity test, the test fails after the tokens expire, how do i regenerate the token just about the expiration time so that the tests do not fail.
Hi Sandeep, i believe you will need to add some script or controllers to track time and get the new token after a specific time duration
Hi Raghav, I am trying to test a OAuth authentication login for a Web App, i can generated the access token, but somehow still getting 400 bad request. even tried to use JSON Extractor to get the token and use in other requests. Can you Advise.
Hi Shaikh, try step by step debugger to check what are the values being referred. Watch this - th-cam.com/video/7JI3GD0ifTw/w-d-xo.html
@@RaghavPal Hi Raghav, it was a help but still something seem to be missing. can you please advise is MS AD login authentication used in a web app can be stimulated or not, I mean is there a possibility to do so.
I will need to check on this Shaikh
I have used UUID to a variable in the request body of POST request..How to extract that variable generated value from the request body after execution and store it for the sampler request in next thread group?
Varsha
To extract the dynamically generated UUID value from the request body in JMeter and use it in a subsequent thread group, follow these steps:
1. Extract the UUID Value:
- In your JMeter test plan, add a Regular Expression Extractor or a JSON Extractor to the sampler that generates the UUID. These extractors allow you to capture specific values from the response.
- Configure the extractor to capture the UUID value from the response body. Specify the appropriate regular expression or JSON path expression to match the UUID format.
- Store the extracted value in a JMeter variable (e.g., `${UUID}`).
2. Pass the Variable to the Next Thread Group:
- To pass the extracted UUID value to a subsequent thread group, you have a few options:
- User Defined Variables:
- Add a User Defined Variables element at the test plan level.
- Define a variable (e.g., `UUID`) with the extracted value.
- This variable will be accessible across thread groups.
- Inter-Thread Communication:
- Use the Inter-Thread Communication PreProcessor.
- Set the variable in one thread group and retrieve it in another.
- Property File:
- Write the UUID value to a property file using a BeanShell PostProcessor or a JSR223 PostProcessor.
- In the next thread group, read the value from the property file using a BeanShell PreProcessor or a JSR223 PreProcessor.
3. Reference the Variable in the Next Thread Group:
- In the subsequent thread group, reference the `${UUID}` variable wherever you need it (e.g., in the request body of another sampler).
- JMeter will replace `${UUID}` with the actual value extracted during execution.
Remember to adjust the variable names and configurations according to your specific test plan. This approach ensures that the dynamically generated UUID is available for use in subsequent thread groups. Happy testing
--
I have a question, I understand your concepts well. this is the scenario. 1) I have to hit POST api, once i hit that responce will be bearer token and after rest of the api's i have to add those token in the header. 2) if i have login api of 100 users, and afterwards i have to hit rest of the apis for each user, everytime when i login the new token will be created, how can i add those tokens to rest of the apis
Sundar
Here's how to handle dynamic bearer tokens for multiple users in JMeter:
1. Extract Token from Login Response:
- Regular Expression Extractor: Add a Regular Expression Extractor as a Post-Processor to the login request.
- Configure Extractor: Set the following properties:
- Reference Name: Choose a meaningful name (e.g., `bearer_token`).
- Regular Expression: Compose a regular expression to capture the token from the response (e.g., `"access_token": "(.+?)"`).
- Template: `$1$` (extracts the first matching group).
- Match No.: 1 (assuming the first occurrence of the token).
2. Add Token to Subsequent Requests:
- HTTP Header Manager: Add an HTTP Header Manager to each request that requires the token.
- Set Header Name and Value: Configure the header name to `Authorization` and the value to `Bearer ${bearer_token}` (using the variable extracted in step 1).
3. Handle Multiple Users:
- CSV Data Set Config: Use a CSV Data Set Config to read a CSV file containing user credentials.
- Loop Controller: Enclose all login and subsequent requests within a Loop Controller.
- Set Loop Count: Set the loop count to 100 (or the number of users in your CSV file).
- Variable Names: Ensure variable names in the CSV Data Set Config match those used in the login request.
4. JMeter Thread Groups:
- Consider Thread Groups: For better control and performance, consider using multiple Thread Groups, each simulating a specific number of users.
Additional Tips:
- Debug Sampler: Use the Debug Sampler to inspect variables and ensure token extraction is working correctly.
- Think Times: Add appropriate think times to simulate realistic user behavior.
- Concurrency: Adjust concurrency settings in Thread Groups to manage load.
- Correlation: If token positions vary, use JMeter's correlation features for dynamic extraction.
Hi Raghav , need a help. Below is my json
{"numFound":1,"docs":[{"Id":"547259","count":1514380,"price":0.0}]}
in Json Path extractor ,while trying JSON Path expressions , its allowing only one value if I try more than One like
$..count; $..Id - not working
Names of created variables - count; Id
Hi, pls check when you give more than one json expressions, you also need to give equal no of variables and default values
@@RaghavPal HI Raghav , Thank you very much , It worked now.
Hi Raghav,
I am working on API testing with Jmeter to validate different set of results from JSON.
My Scenario is
1. Run API & extract and store variables. (completed as above)
2. COmpare the values (the Json with values A,B,C,D and have to verify B=A+C , and publsih True or False )
How to perform these arithmetic Operations in Jmeter & Say True or False ? Please help. Thank you.
Hi, for this you will need to add some custom scripts. Can check www.blazemeter.com/blog/scripting-jmeter-assertions-in-groovy-a-tutorial/
@@RaghavPal Thanks Raghav , Yeh I tried it - www.blazemeter.com/blog/using-operations-on-variables-in-jmeter/
Hi Raghav , i need to make a script like if status code is not 200 then mail should be triggered to me through jmeter . can u please give me an idea how can i implement.
Hi Rajesh, you will have to write BeanShell script for that.
Automation Step-by-Step - Raghav Pal can u please make a video on it ...it will be really grateful.
Will do it Rajesh
Hi Raghav, thanks for your tutorials. It's been most useful. One small suggetion is that please increase the audio/sound for your tutorials. It is very low and even with 100% volume in the computer it is very low. Tried with different systems and different headsets but its the same. Please look into this.... Regards :-)
Hi Parmod, thanks for the feedback. I hope you have increased the player volume too. I will take extra care of audio in future videos
Hi Raghav, I need to pass the variable from the json extractor of the 1 request into the body of the 2nd request. (instead in the URL) . Tried the syntax from the video but it didnt work if I use the extracted variable in the request body of the 2nd request. Please let me know, how we can achieve it?
Hi Saurabh, You just need to parameterize the value where you want to use the extracted data and refer it from a user variable. And during executed when you extract the value, update the user variable with it and the next request will refer it from there.
Hi Raghav! I am doing jmeter using api, I am passing huge data through csv file and running my scripts. My scripts run for nearly 3 to 5 hrs. I have some failures where i can verify from tree, assertions, and from failure csv data file reports.....but for failed reports I have to manually verify in postman and check the cause of failure , and for that i need to pass (POST-Request Body) manually. I cannot do it for multiple data's, so I want to extract whole Request Body from jmeter and display in my html report and then when ever i want i can analyse failure request and hit in postman directly. How do I extract Request Body?
Hi Nazneen, have you tried providing a csv file location in teh View Results Tree or other listener in File name section. BTW you should not use View Results Tree listener while doing actual performance test as it is memory consuming listener. Some links that may be helpful
www.blazemeter.com/blog/how-to-save-response-data-in-jmeter/
stackoverflow.com/questions/1515689/jmeter-how-to-log-the-full-request-for-a-failed-response
how can we use json extractor to Extracting data from json response and chaining requests in jmeter
Hi Akash, you can extract data from json as shown in this video and then you can use the variables in any subsequent request, for e.g. if you stored extracted value in a variable called User1, In any future request you can use ${User1} to refer
Hi Raghav
Is it possible to use conditional json extraction like when id=4 what is the first name of user in jmeter 5.1.
Hi Dhana, I have not used it, but check this
dzone.com/articles/advanced-usage-of-the-json-path-extractor-in-jmete
stackoverflow.com/questions/43444277/jmeter-json-path-extractor-conditional-selection
Hi Raghav. How to loop through json extractor values and call next http request. Can you please let me know
You can use a while loop, Can find examples online
@@RaghavPal thank you
well explain sir i like your turtorials
Thanks Rahul. Can check all here - automationstepbystep.com/
What should do if we want to pass multiple id's from previous response to further request URL which changes dynamically
Hi Preeti, can extract and store in multiple variables
is there a way to read external Json file and use the values in it ?
Hi Sayali, I believe you will need to add some scripting for that. I have not tried, can get some help here - stackoverflow.com/questions/30589715/how-to-read-external-json-file-from-jmeter
Hi Raghav,
Could you please elaborate why we have to give default value for json extractor when you have used more than one variable and json path expression?
Hi Jaspreet,
It is just that if nothing gets fetched with the JSON path, this value can be used. You can keep it empty.
Hi Raghav, Can I use Json extractor to extract all values of Json response into a csv file into different rows and columns? Do you have any video on this?
Hi Saranga, I believe there is no direct way and you will have to add a script sample as a child of json extractor and add the script to write results to csv. This can help
stackoverflow.com/questions/35742949/extracting-a-value-from-jmeter-response-and-exporting-it-to-a-csv-file
Hi! I have csv data file with multiple data say 50 or 100....now how do i do json extractor by making use of csv data and then extract data and display in HTML reports.....Plz help me to sort out this issue.
Hi Nazneen, have you tried csv data set config to get data from csv. You can store in variables and use the variables in other elements like JSON extractor
I have to test an API, firstly HTTP request is running and then JSON extractor so it is throwing an error because no value is getting passed, I have kept it as a child. So, how to get the value from Json Extractor and pass it?
Hi Ashita, first make sure you are getting the value to be extracted in the response and after that you can use the JSON extractor as shown in the video. Let me know where exactly you faced the issue. Ensure you create right json path
@@RaghavPal Yes, Raghav..I have taken out the value from the response, verified it using the tool - jsonpath.curiousconcept.com
Still, I'm not getting the value, when I am debugging, firstly the request is running and then the JSON extractor. One more thing, JSON has an array.
Hi Ashita, have you tried to debug and check if the right values are getting extracted. Check this - th-cam.com/video/7JI3GD0ifTw/w-d-xo.html
Sir, I a trying to automate one of the REst API using JMeter using HTTP request but there is a problem coming stating 400 bad request. I provided the username and Password in the HTTP Authentication manager, this does not worked.Could you plz helped me out may be with videos.plz
Hi Anil, 400 is for bad request, So I believe the issue is not with authorization but your request. Try to check all your request parameters, Check for any typo, spaces etc.
Hi Raghav,
May I know why we use JSON Extractor in JMeter?
Hi Prasad, you will need it when you are doing any API test having JSON response. This can be used for multiple things, e.g.
To fetch a value from response and store in a variable to assert it
Pass the value to any other subsequent request
To validate/assert node count in json
etc.
I will have new videos to explain some of these.
Hi Raghav, can you please make a video of how to use JSON extractor for combination of POST and PUT API requests having body parameter?
It will be very helpful
Hi Vivek
I will plan
Raghav this is very helpful
Glad to know that Vishal
Thanks Ragnav, great tutorials!
I have a question about JSON extraction. What if i need to cycle though values in ${USER1} like ${USER1_1}, ${USER1_2}, etc?
I have multiple images, which are to be loaded, if response is not empty, so i call If statement, then extract url of images using JSON Extractor,
but after i dont know how to cycle request using those images url's. Maybe you have some advise?
Hi MrSirling, you can use a while loop
Thankyou Raghav, very useful.
You're welcome Namrata
Hi, how can I use the data extracted using JSON extraction in the next http request body?
Hi Ajay, You just need to call with the syntax ${varName}, I think this is shown in the video, Pls check - th-cam.com/video/3w0x6u4-6ng/w-d-xo.html
Hi Raghav, How can I fetch the extracted value in JMS Publisher? I don't see the Path option to pass the json extracted variable in JMS Publisher? Any suggestions please?
Hi Kalyani, which field exactly do you want to refer the extracted value. Ideally you can refer it anywhere with the syntax
${variableName}
Thanks Raghav. It worked.
Hi Raghav - I am able to extract value 'ID' from the 1st Subscriber and fetch it in the 2nd Publisher with the syntax ${variableName}
. But not able to fetch the same ${Id} in my 3rd Publisher?? Any Suggestions? I did used ${Id} in my file and jMeter seems to be working fine.. like I see the correct 'ID' in the Response Data for the 3rd Publisher but in general it is not fetching the 'ID' for the 3rd Publisher?
nm figured it out.. Thanks!
hello sir can you tell me the best certification for jmeter. I have one Vskills for jmeter plz tell me which is best.
Answered your other comment Abhinav
Automation Step by Step - Raghav Pal Hello sir no answer recived on the other commt, sorry for the tje same commt but plz let me know which is best plz sir i need it urgent so i can apply before sept.
it was helpful!
Happy to know this Deepa
Thank you so much for this video :)
Most welcome
But how can we add the assertion to verify if we have got correct results of JSON, please guide.
Hi Sanket, you can add response assertion or others as per your need, There is a video on assertions, pls check. automationstepbystep.com/online-courses/
Hi Rahgav , When using step by step debugger it's skipping JDBC configuration configuration and because of that validate login request is getting failed .Could you please give some idea to implement this .
Hi Sonia, as per this page github.com/Blazemeter/jmeter-debugger The known limitations of step-by-step debugger is
Only one thread group at a time can be debugged (evaluate panel allows to mitigate the limitation)Module Controllers and Include Controllers are not supported
Just check if your element falls into any of this
Hi Raghav, IS it possible to read Json file as API request in Jmeter
Hi Sriram, This will help - www.testingexcellence.com/jmeter-tutorial-how-to-send-a-json-file-as-request-in-body/
www.blazemeter.com/blog/how-to-use-the-json-plugin-in-jmeter/
great.... if i use -1 then i have to run a loop for next request. how could i do this?
Hi Sym, did not understand your issue completely.
Hello.. i mean if I use match no = -1 in json extractor. then it will return an array of variable... if i want to use the extractor variable in next http request..which is inside an array.. then i need a loop... you use specific variable ${User1}...... i did it by using
foreach controller... is there any other way?
not sure, will have to check this
hi raghav, awesome video. but I have one query suppose in a single variable multiple I'd are stored in case of -1.so which I'd is passed in subsequent request.
Hi Sumit, glad to know it helped. As i explained in the video, if you use -1 in Match No. field, than all the values matching the expression will be stored in variable and the variable name will be updated.
E.g. If you have used variable name User and there are 2 values, then 2 variables will be auto-genrated
User_1 & User_2 . and you have to pass these variables to any subsequent request.
Hi Raghav ,
one more time i need your help , while running all script getting 200 status but in table it is showing it get failed .
Hi Rajesh, Is there any assertion that you have put and is getting failed. Add listener view results tree and see what exactly is the failure
i have created the same test again as new with all same parameter and it run . strange..:) anyways thanks
When I am using $..id; $..first_name in json path exp. it is not working
it is working for one variable only
Chandrima
When using the JSON Extractor in JMeter, it's important to ensure that you're using the correct syntax for extracting multiple values. If you want to extract multiple values into different variables, you need to separate the variable names and JSON path expressions with semicolons and provide a default value for each variable.
Here's how you can configure the JSON Extractor for multiple variables:
1. Variable Names: Specify the names of the variables you want to create, separated by semicolons.
2. JSON Path Expressions: List the JSON path expressions corresponding to each variable, separated by semicolons.
3. Default Values: Provide default values for each variable, separated by semicolons.
Here's an example configuration:
- Variable Names: `id;first_name`
- JSON Path Expressions: `$..id;$..first_name`
- Default Values: `NOT_FOUND;NOT_FOUND`
This configuration will create two JMeter variables named `id` and `first_name`, each extracting values from the JSON response based on the provided JSON path expressions. If the JSON path does not find a match, it will assign the value `NOT_FOUND` to the respective variable¹².
Make sure that your JSON response structure matches the JSON path expressions you are using.
If you continue to face issues, you might want to verify the JSON path expressions with a tool like JSONPath Online Evaluator to ensure they are correct.
what if I want to use the value extracted from a request of thread-group 1 and I want to use that value in thread-group 2
Hi Shilpa, in that case you will have to store the extracted value in a property. Some links to help you
medium.com/@priyank.it/jmeter-passing-variables-between-threads-a4dc09903b59
www.testingexcellence.com/jmeter-pass-variables-between-thread-groups/
Very useful. Thank you
You're welcome Sameera
Hi Raghav
At first thanks for preparing awesome tutorial...
How can i use JMeter assertion to validate JSON schema of REST response?
Thanks
Hi Saddam, I could see XML schema assertion in JMeter, but nothing on JSON schema, you might have to do some custom scripting for this, but do check online thoroughly, i might have missed it.
Thanks for the reply....
I was just checking is there any available option available in JMeter, which i might have missed to explore or unaware of...
Yes you are right I need to right custom JSON schema assertion...
I have added 3 HTTP Request, I am getting auth token from the first request and I want to use this for rest 2 request. I used JSON Extractor and getting auth token in the second request, and applied the same thing in the third request but not getting auth token, it gives me an Unauthorized error, can you please help me how I can get it?
Thanks in advance!!
Hi Mayur, mostly it might be due to incorrect implementation. To get to the root cause I will need to check your setup and test. Do you have any logs? Also you can use debugger to troubleshoot. - th-cam.com/video/7JI3GD0ifTw/w-d-xo.html
Thanks Raghav
You're welcome Jagriti
How to store pricepack.client.clientid in json path extractor $..pricepack.client.clientid is not working
Hi Shafi, will have to see your json and regular expression
@@RaghavPal {
"data": {
"count": 1,
"rows": [
{
"servicepricepackmapId": "d3714040-f555-11e8-b681-bf83d046c304",
"serviceId": "c13966f0-f555-11e8-b681-bf83d046c304",
"businessId": "d6d546d1-e733-11e8-aa79-63929593d229",
"pricepack.pricepackId": "cfaff280-f555-11e8-b681-bf83d046c304",
"pricepack.pricepackName": "Pack 5",
"pricepack.subscription.subscriptionId": "3f4f0684-2446-48e5-8905-4fc59b3182ae",
"pricepack.subscription.client.clientId": "e4293050-f555-11e8-b681-bf83d046c304",
"pricepack.subscription.client.clientName": "Golu",
"pricepack.subscription.client.contactNumber": "9799681583",
"pricepack.subscription.client.emailId": null,
"pricepack.subscription.client.photoUrl": null,
"name_initials": "G",
"bookingNames": null,
"isAdded": 0
}
]
},
"error": {
"errorMessage": "Success",
"errorCode": 200
}
}
Hi Shafi, sorry for late response, I just checked with some online json formatter, looks like its not formatted and is shown invalid json
Hi Raghav! Thanks for the tutorials.
Also could you please help in how to state a condition while using extractors.
for eg:
lets say there is a json response which contains an attribute "price" and I want to extract it only when the price is greater that 5.
Hi Ayushi, so here you will need to extract the value and then use some conditional statement and store in a new var based on this condition
Thank you!
You're welcome
Gm :)