Forum Discussion

QATest's avatar
QATest
Visitor
9 years ago

Update headers to multiple test steps

Is there a way to add multiple headers to test case level rather than each individual test step level?

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Thank you rupert_anderson for pointing the script.

    QATest, it is little confusing when you say "multiple headers to test case level". Because, headers are applicable only to the test steps that uses http transport protocol.

    Did you try the script pointed by Rupert earlier?

    If you have different requirement, please elaborate the question.

     

    I am assuming that you have multiple test steps (soap / rest / http  request ) and you want those headers to all steps of that test case? 

     

    Then you can add the script into Setup Script of the test case with minor modification of the earlier pointed script.

     

    Here is the modified script, you can change the headers as needed.

    https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/AddHeadersToMultipleSteps.groovy

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    Do you mean for a given TestCase, you want to add a set of headers to each request TestStep within it automatically?

     

    If so, I noticed nmrao wrote a nice script to automatically add headers at a TestStep level:

     

    https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/SetHttpHeaders.groovy

     

    This could be adapted to iterate over all TestSteps in a TestCase - Rao do you already have a script like this?

     

    You can also add request filters to automatically add headers when requests are despatched, but this is generally a more complex process. Can explain more about this if necessary.

     

    Regards,

    Rupert