Retrieve the cookies and other header info from HTTP response in Jmeter

If you want to access http response header values, you can use below steps

  1. Add http request samples in the thread group
  2. If you want to do assertions on header values, You can use assertions elements
  3. If you want to just store header values into variables, You can use Post processor elements

Response Assertions in Jmeter

  1. You can assert on various type of info like text response and Response headers, Response message
  2. To access the cookie, you need make sure that CookieManager.save.cookies=true in jmeter.properties file and ensure that you have added HTTP Cookie Manager config element to your test plan
  3. Then you can access the cookie variables using syntax like ${COOKIE_MyCookieName}

Respone assertions

Regular expression extractor – Post processor

  1. You can use regular expression extractor to retrieve and store the date from the response header or body
  2. You can access stored variables in subsequent requests using syntax like ${MyVar}

 

JSR223 post processor

  1. You can use groovy script to print any variables or do complex calculations in Jmeter. If you want to view all Jmeter variables, you can use “Debug Sampler” element.
  2. To print the values, you can use syntax like log.info(“${COOKIE___cfduid}”)

 

JSR223 Post Processor

You may also like...