Forum Discussion

NicoF's avatar
NicoF
Occasional Visitor
10 years ago

Response get Header

Hi everyone,

 

Is there a way to get the header-data(raw) from response in a teststep? I want to extract informations from there and i have no idea.

 

Thanks a lot.

 

regards

Nico

  • Lucian's avatar
    Lucian
    6 years ago

    You only need to add an index like:

     

    def value = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["param name"][0]

    Cheers!

  • Yep, use responseHeaders["parameter name"] in Groovy, for example:

    def value = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["param name"]

     

    Of course, you must know the param name but I assume you do

    • nagoorkj's avatar
      nagoorkj
      Contributor

      Hi ,

       

      Currently it is returning with Square Brackets so is there any other way to read values alone .

      eg. [myheadersValues]

      i need without [] array brackets

      • Lucian's avatar
        Lucian
        Community Hero

        You only need to add an index like:

         

        def value = testRunner.testCase.testSteps["Request"].testRequest.response.responseHeaders["param name"][0]

        Cheers!