Forum Discussion

raviraj's avatar
raviraj
Occasional Contributor
7 years ago

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

Hi,

 

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 ?

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    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()
    log.info(headers)
    

     

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

      

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

     

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

    • saimie's avatar
      saimie
      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"]
      log.info(headerValue) 

       

      Thanks,

       

      Sam