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:

  • Understanding JMETER Listeners Understanding Listeners in JEMTER  :-  Listener displays particulars of sampler requests and responses, and can display basic HTML and XML representations of the response. Other listeners deliver summary or a… Read More
  • Creating Test Plan in JMETER Creating Test Plan in JMETER How to create test plan in JMETER for REST API performance testing? For REST API performance testing we have to start with Test plan in JMETER. The test Plan is where the overall settings… Read More
  • 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
  • Performance Testing Overview Performance Testing Overview Before starting to understand about  Performance Test life cycle  we  need to understand  What is Performance Testing  What is Performance T… Read More
  • JMETER -Understanding Thread Group In this part of step by step JMETER tutorial we are going to learn about JMETER element “THREAD GROUP” What is Thread Group in JMETER:- Thread group is a place where we actually put number of users (Thread… Read More

0 comments:

Post a Comment

Popular Posts