Forum Discussion

raviraj's avatar
Occasional Contributor
7 years ago

How to read or get all cookie values from the response ?



Currently I have a response which has 2 Cookies in the response lets say

Name=A, value=ABC, Domain=D, Path=/, Http=false, Secure=false

Name=B, value=XYZ, Domain=M, Path=/, Http=true, Secure=true


But in Soapui I can only view 

B=XYZ;Path=/;Secure;HttpOnly response under Headers [Set-Cookie]


But from Postman I am able to view both the cookies.


In Soap UI is there any way to read both the cookie name and values ???


Or any groovy script for the same ?

3 Replies

  • Nastya_Khovrina's avatar
    SmartBear Alumni (Retired)

    Hi Ravi,


    Thank you for your post. You should get all cookies in the Response editor if they were received. 


    BTW, here is the script to get all response headers:


    def headers = testRunner.testCase.testSteps["Test_Step_Name"].testRequest.response.getResponseHeaders()


    and specific response headers (for example, Set-Cookie):


    def headerValue = testRunner.testCase.testSteps["Test_Step_Name"].testRequest.response.responseHeader["Set-Cookie"] 


    You can use the mentioned scripts in the Groovy Test Step. 

    • saimie's avatar
      New Contributor

      Hi - the script below is incorrect. You will need to run the following script for specific response headers: 


      def headerValue = testRunner.testCase.testSteps["Test_Step_Name"].testRequest.response.responseHeaders["Set-Cookie"]