Forum Discussion

Rakinson23's avatar
Rakinson23
Occasional Contributor
5 years ago
Solved

How to get data from raw response and set it as property for test case by groovy

Hi Bears, From my request I'm only able to receive RAW response with data: HTTP/1.1 201 Date: Thu, 06 Jun 2019 23:02:56 GMT Content-Length: 0 Connection: keep-alive Location: https://xyz.y...
  • SorinC's avatar
    5 years ago

    Hello Rakinson33, 

     

    Can you try with this groovy script?

     

    // Get the cartId header
    def cartId= testRunner.testCase.getTestStepByName("TestStep").httpRequest.response.responseHeaders["cartId"][0]
    
    // Set a test case property for the header
    testRunner.testCase.setPropertyValue( "cartId", cartId)

     

    Regards