groovy script to add HTTP step in test case
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 add HTTP type step in added test cases.
Please help.
Thanks
Sachin chanchal
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rao,
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
tc.addTestStep(GroovyScriptStepFactory.GROOVY_TYPE, "TestStep1")
tc.addTestStep(GroovyScriptStepFactory.GROOVY_TYPE, "TestStep2")
But unable to find the way to create new test step in desired test case.
OR
if I will get got groovy code to copy Test step from one test suite to another then that will also work for me...
Please suggest
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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)
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"
Username="ABC"
Password="DEF"/>
means: how can we add XML request in a body of created test step
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 )
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
for e.g
PROJECT1
|
___Test Suite 1
__Test Case1
___Test Step1
___Test Suite2
___Test Case2
would like to clone Test Step1 from Test Case1 to Test Case2
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
