Thursday, March 9, 2017

SOAPUI : Access Properties at different levels (Property Expansion)

Access Properties at different levels (Property Expansion)


Property Expansion(http://readyapi.smartbear.com/features/expansions/syntax) :

1) TestStep properties =  ${TestStepName#MyPropertyName}
2)Test case properties =${#TestCase#MyPropertyName}   -- Here TestCase is keyword
3)Project properties =   ${#Project#MyPropertyName}  --- Here Project  is keyword

Examples:
log.info context.expand('${#TestCase#endpoint3}')   // Groovy
or
Directly use : ${#TestCase#endpoint3}
In any Request


Using Properties values from a different testcase :


-----Working with current test case -----------
SET    :     testRunner.testCase.setPropertyValue("endpoint",endpoint)
GET :       log.info testRunner.testCase.getPropertyValue("endpoint")


----------------------------Working with some other test case -------------
get Value :
def project = testRunner.testCase.testSuite.project
log.info project.testSuites['TestSuite 1'].testCases['TC anme'].getTestStepByName("StepName").getPropertyValue("property_name")

Example :
def project = testRunner.testCase.testSuite.project
log.info project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].getTestStepByName("Count").getPropertyValue("authentication_PropertyFile")

Wednesday, March 8, 2017

SOAPUI : Extract xml response

Extract xml response


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
responseContent = testRunner.testCase.getTestStepByName("TestStepname").getPropertyValue("response")
//"response" is keyword

def holder = groovyUtils.getXmlHolder(responseContent)
log.info holder.getNodeValue("//locale/recordId")  // Here "locale/recordId" is like  //Parentnode/node

SOAP UI : Call Another Test Case using Groovy script

Call Another Test Case using Groovy script


RUN TEST CASE

def project = testRunner.testCase.testSuite.project
def runner = project.testSuites['Suite_name'].testCases['testCase_name'].run( null, true )
runner.waitUntilFinished()

example :
def project = testRunner.testCase.testSuite.project
def runner = project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].run( null, true )
runner.waitUntilFinished()

RUN TESTSTEP

def project = testRunner.testCase.testSuite.project
testRunner.runTestStep( project.testSuites['TestSuite1'].testCases['TestCase2'].testSteps['GroovyScript'] )

example:
def project = testRunner.testCase.testSuite.project
testRunner.runTestStep( project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].testSteps['initialization'] )





Ref : 
https://community.smartbear.com/t5/SoapUI-NG/Res-Calling-test-cases-and-test-steps/td-p/18186/page/2