cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving a cookie from response header using Groovy

SOLVED
Highlighted
New Contributor

Retrieving a cookie from response header using Groovy

Could you help me how to retrieve a cookie from response header using Groovy?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Try something like this 

 

def cookie_name = testRunner.testCase.testSteps["Request_Step_Name"].testRequest.response.responseHeaders["Cookie-Name"]

log.info cookie_name

 

// Change Cookie-Name to whatever the name of the header name you are looking for

View solution in original post

3 REPLIES 3
Highlighted
Contributor

Try something like this 

 

def cookie_name = testRunner.testCase.testSteps["Request_Step_Name"].testRequest.response.responseHeaders["Cookie-Name"]

log.info cookie_name

 

// Change Cookie-Name to whatever the name of the header name you are looking for

View solution in original post

Highlighted
New Contributor

Hi, Tried the above code but getting NULL as result. Its a browser generating cookie. So can we get browser generating cookie using groovy?

Highlighted
Senior Member

bagochip's example should work for you if you correctly replace

"Request_Step_Name" with your test step and "Cookie-Name" with the correct response header name in which you are getting the cookie value

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors