ADS

Monday, April 1, 2013

Basic Groovy Scripts commands for SOAPUI

Using Groovy scripts in SOAPUI can help you do lots of stuff but beginning with this feature can be at times difficult for new users. Following are the commands that you can find really useful for starting with Groovy scripts in SOAPUI.

Go to the project level using the command
def project = testRunner.testCase.testSuite.project

Access the Test Suite using the following commands
def testsuite = project.getTestSuiteAt(index)
def testsuite = project.getTestSuiteByName("TestSuite Name")

Access the Test Case using the following commands
def testcase = testsuite.getTestCaseAt(index)
def testcase = testsuite.getTestCaseByName("TestCase Name")

Access the Test Steps using the following commands
def teststep = testcase.getTestStepAt(index)
def teststep = testcase.getTestStepByName("TestStep Name")

Run a Test Step using the following command
teststep.run(testRunner,context)

set property value at different level of hierarchy

set property at Project level
project.setPropertyValue("property_name","value") 


set property at TestSuite level
testsuite.setPropertyValue("property_name","value") 

set property at TestCase level
testcase.setPropertyValue("property_name","value") 

get property value from different level of hierarchy

get property from Project level
project.getPropertyValue("property_name")


get property from TestSuite level
testsuite.getPropertyValue("property_name")

get property from TestCase level
testcase.getPropertyValue("property_name") 


get the count of number of TestSuites, TestCases and TestSteps
project.testSuiteCount // get TestSuite count in the project
testsuite.testCaseCount // get TestCase count in the TestSuite
testcase.testStepCount // get TestSteps count in the TestCase
Any other basic commands which you feel should be added in the list please provide in the comment section.

1 comment: