Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract Cookie Data from Jmeter Request

Tags:

regex

jmeter

On Jmeter: View Result tree: Request: Raw

Cookie Data:
.ASPXAUTH=EBB383A4DA12F0C106F044F70EC6CD6637252490DA31179407C466B8933D8B32622584F7A9F18A40C9D423078313E6ACB89519497CDDED451AF0C857AF3D6ED1C12296E56CE7D6058D7450E74B845EE39F3404925F679F180493329BDA021698

Regular expression extractor

Main Sampler Only
Request Headers
Regular Expression : Cookie Data:(.*)
Template : $1$
Match No : 1

Still getting Null Value

Also tryed with

Cookie Data:\n(.*)

Please Suggest.

like image 457
Chitta Ranjan Avatar asked Feb 09 '17 10:02

Chitta Ranjan


People also ask

How to use JMeter extract and re-use key?

You can use the regular expression extractor to extract the key from the response of your first request and use the extracted key for subsequent requests. We call this JMeter Extract and re-use. Here are the steps: Right click on the first request and add post processor: Regular Expression Extractor.

How are cookies handled in JMeter?

Cookies are handled in JMeter using ‘HTTP Cookie Manager’. Using this config element you can simulate browser activities. HTTP Cookies Manager does work in two ways:

How do I use the XPath extractor in JMeter?

To demonstrate the use of the XPath extractor, let us assume the following response for one of my HTTP requests in JMeter: We can extract fromPort values and toPort values into two different variables and then pass it on to the next request.

How do I run an HTTP request in JMeter?

Open Apache JMeter (here is how to start Apache JMeter on Mac) and right click Test Plan and Add -> Threads (Users) -> Thread Group 2. Right click Thread Group and Add -> Samplers -> HTTP Request


2 Answers

Given the value is stored in the HTTP Cookie Manager, you can access it using below steps:

  1. Add CookieManager.save.cookies=true line to user.properties file
  2. Restart JMeter to pick the property up
  3. Access the cookie value as ${COOKIE_.ASPXAUTH} where required.

See Using the HTTP Cookie Manager in JMeter article for more detailed explanation of the above steps

like image 176
Dmitri T Avatar answered Nov 15 '22 09:11

Dmitri T


In Regular Expression Extractor, under Field to check, please select Response Headers radio button.


To save Cookies automatically, In jmeter.properties file, set as following:

CookieManager.save.cookies=true

Restart Jmeter.

You can access the saved cookies with COOKIE prefix.

example (in your case):

${COOKIE_Cookie_Data} # confirm the same in debug sampler result in View Results Tree

I strongly suggest adding Debug Sampler & View Results Tree, which shows the saved cookie values.

like image 34
Naveen Kumar R B Avatar answered Nov 15 '22 10:11

Naveen Kumar R B