Wednesday, January 9, 2019

 To parse JSON response we need to use JSON Extractor and Bean Shell Post Process (Here we need some do coding) Add JSON Extractor & Bean Shell post processor to thread group Right click on Thread Group> Add>Post Processor
JSON Extractor & Bean Shell post processor added to thread group 



We are capturing “geoAddressId” and will save it in CSV 





How to Configuring JSON Extractor to Parse JSON Response in JMETER For API  performance Testing


 Variable Name:- You can set any variable name to which Extracted geoAddressId value to be assigned and stored in memory 


JSON Path Expression:-  It allows you to enter search criteria to search Parameter ( you can google Regular Expression for more details ) 

Match No:- 

Default Value- If geoAddressId not found then it will save default value “No geoAddressId found” 


Now we want to save value stored in memory to CSV file, for this we need to write Bean shell Script in Bean shell Post Processor. Open bean shell Post processor. And write below script

import java.io.FileOutputStream; 
import java.util.Map; 
import java.util.Set; 
import java.io.FileWriter; 
String str=vars.get("geoAddressId"); 
FileWriter writer = new FileWriter("D:\\Performance\\Test1\\Test Data sheets\\ADDRESS BS\\geoaddressid.csv",true);  
writer.write(str); 
writer.write("\t"); 
writer.write(System.getProperty("line.separator")); 
writer.close(); 



Now run performance test with 5 users, and check Response as well as geoAddressId stored in CSV 

All 5 users got success


Also in Data sheet all 5 geoAddressId are saved




Related Posts:

  • API performance testing using JMETER  API performance testing using JMETER In this article we are going to learn about How to use step by step JMETER for API Load and Performance testing . Basic information and details about JMETER and what is web… Read More
  • JMETER Tutorial Course Content JMeter Download JMeter Overview JMeter  Enviornment JMeter  Build test plan JMETER -Understanding Thread Group Understanding Listeners in JEMTER API performance testing using JMETER How to pass variable data… Read More
  • Solution- JMTER not working from CMD / NON GUI / Command Promt I was facing this issue when I was trying to run JMETER from CMD/ Command prompt / Non Gui, Even JMETER was working fine in GUI mode. To run I started JMETER in Bin path of JMETER and ran below query C:\tools\… Read More
  • Parsing JSON response and Saving it in CSV  To parse JSON response we need to use JSON Extractor and Bean Shell Post Process (Here we need some do coding) Add JSON Extractor & Bean Shell post processor to thread group Right click on Thread Group> Add>… Read More
  • How to pass variable data in JMETER request How to pass variable data in JMETER request How to use CSV data set config in Jmeter for passing varible data in JSON request  To create real-time scenario we need to pass variable data in request. For this we can… Read More

0 comments:

Post a Comment

Popular Posts