SOAPUI - SOAPRequest - Expand properties to access name property of current TestStep

烈酒焚心 提交于 2019-12-05 18:49:36

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}

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>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!