Question

SoapUI provides a common syntax to dynamically insert properties in SOAP Request. In their documentation they explain how to access different properties depends on property scope:

#Project# - references a Project property
#TestSuite# - references a TestSuite property in the containing TestSuite
#TestCase# - references a TestCase property in the containing TestCase
#MockService# - references a MockService property in the containing MockService
#Global# - references a global property (optional)
#System# - references a system property
#Env# - references a environment variable
[TestStep name]# - references a TestStep property within the current TestCase

My problem is I want to access the name of the current testStep however documentation says that to access TestStep properties you need the name... There is another way to do so? like for example #TestCase#TestStep#Name. I know how to achieve this with groovy script but in my case I want to put the property directly on SOAP Request.

Thanks in advance

Was it helpful?

Solution

Finally I found the solution in the documentation, with '=' prefix it's possible to specify a groovy script and access to some context variables. In this context request variable is available and also its name property, so It's possible access to the current TestStep name with:

${=request.name}

OTHER TIPS

Example below is grabbing the request from your TestCase and assigning a value to a specific element.

// get XMLHolder for request message def
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);

// grabbing the specified request
def holder = groovyUtils.getXmlHolder("Specified#Request")

holder["//*:Password"] = 'password1';

For the example above you need to know the Xpath for your element.

Note, that this can be accomplished in several ways, but you specified doing in through groovy script. It can also be done through a #TestCase# property. Example:

 <soapenv:Body>
  <tns:AuthenticateUser>
     <tns:Credentials>
        <tns:IntegrationID>${IntegrationID}</tns:IntegrationID>
        <tns:Username>${Username}</tns:Username>
        <tns:Password>${Password}</tns:Password>
     </tns:Credentials>
  </tns:AuthenticateUser>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top