Forum Discussion

sachin-chanchal's avatar
sachin-chanchal
Occasional Contributor
8 years ago

groovy script to add HTTP step in test case

Hi, I am looking for a groovy script by which i would able to add HTTP type step in my test case. I am able to create/add test case in desire test suite but unable to find a groovy code/script to ad...
  • nmrao's avatar
    nmrao
    8 years ago

    sachin-chanchal, thank you for the details.

     

    Try:

     

    import static com.eviware.soapui.impl.wsdl.teststeps.registry.HttpRequestStepFactory.HTTPREQUEST_TYPE 
    //Provide the http request endpoint in the below
    def endpoint = 'http://google.com'
    //Valid http method GET | PUT | POST | DELETE etc
    def method = 'GET'
    def stepName = 'httpRequestStep'
    
    //Adds http request step to given test case assumes tc is valid object of TestCase
    tc.addTestStep(HTTPREQUEST_TYPE , stepName, endpoint, method)

     

  • nmrao's avatar
    nmrao
    8 years ago

     

    sachin-chanchal,

     

    Try:

    //Assign the step object of the required test step in the below statement
    
    def step =
    
    def request = """<Request Object="System" Action="Logon"
    Username="ABC"
    Password="DEF"/>"""
    step.testRequest.setRequestContent( request )