Forum Discussion

shubhimu's avatar
shubhimu
Contributor
6 years ago

How to get MethodType of Http Request using groovy

Hi All,

 

I have a requirement where in i need to get the MethodType of Http Request using groovy.

 

Can some one help me with that ?

 

Thanks,

Himanshu

2 Replies

  • Radford's avatar
    Radford
    Super Contributor

    I think the following code when placed in a Groovy test step will return what you are after:

     

    log.info(testRunner.getTestCase().getTestStepByName('Your HTTP Request Step Name').getRequestStepConfig().getMethod())

     

    The HTTP Request test step is an instance of the class HttpTestRequestStep.

     

    • shubhimu's avatar
      shubhimu
      Contributor

      Thanks for Posting your answer!

       

      I also got this using below way:

      tc=testRunner.testCase.testSuite.getTestCaseAt(0)
      myRequestStep = tc.getTestStepByName('Request')
      String requestMethod = myRequestStep.testRequest.method