groovy script to add HTTP step in test case
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 add HTTP type step in added test cases.
Solved! Go to Solution.
In my current scenario, I am able to create test suite and test case by groovy script
suite = context.testCase.testSuite.project.addNewTestSuite(suiteName)
and in another groovy, I am using the below shown code for creating a test case
def testSuite = context.testCase.testSuite.project.getTestSuiteByName(suiteName);
def tc = testSuite.addNewTestCase(tcName)
Now I want to add "HTTP" test step under above-created test case, I got code to create groovy step in test case
But unable to find the way to create new test step in desired test case.
if I will get got groovy code to copy Test step from one test suite to another then that will also work for me...
@sachin-chanchal, thank you for the details.
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)
Thanks a lot, Rao, it works...
another Help, How could I add XML request in newly created POST type test step
I am able to create test step by your code now I want to add below-shown XML in HTTP request
<Request Object="System" Action="Logon"
means: how can we add XML request in a body of created test step
//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 )
Thanks for your responses, it really works..I have an another query
Looking for a groovy code which will copy test step from one test suite and clone the same step to another test suite
___Test Suite 1
would like to clone Test Step1 from Test Case1 to Test Case2