Properties SOAPUI-SOAPRequest-展开属性以访问当前TestStep的name属性

Properties SOAPUI-SOAPRequest-展开属性以访问当前TestStep的name属性,properties,soapui,Properties,Soapui,SoapUI提供了一种通用语法,用于在SOAP请求中动态插入属性。在他们的文章中,他们解释了如何根据属性范围访问不同的属性: #Project# - references a Project property #TestSuite# - references a TestSuite property in the containing TestSuite #TestCase# - references a TestCase property in the containing TestCase

SoapUI提供了一种通用语法,用于在SOAP请求中动态插入属性。在他们的文章中,他们解释了如何根据属性范围访问不同的属性:

#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
我的问题是我想访问当前testStep的名称,但是文档中说要访问testStep属性,您需要名称。。。还有别的办法吗?比如#TestCase#TestStep#Name。我知道如何使用groovy脚本实现这一点,但在我的例子中,我希望将该属性直接放在SOAP请求上


提前感谢

最后我在中找到了解决方案,使用“=”前缀可以指定groovy脚本并访问一些上下文变量。在此上下文中,请求变量及其name属性可用,因此可以通过以下方式访问当前TestStep名称:

${=request.name}

下面的例子是从TestCase中获取请求,并为特定元素分配一个值

// 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';
对于上面的示例,您需要知道元素的Xpath

// 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';
请注意,这可以通过几种方式实现,但您指定了通过groovy脚本来实现。也可以通过#TestCase#属性完成。例如:

 <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>

${IntegrationID}
${Username}
${Password}

我知道如何使用groovy脚本访问属性和设置请求值,我被问到的问题是如何使用属性扩展将TestStep名称放入请求中。使用${name}正如您在回答中指出的那样不起作用,最后我使用${=request.name}来实现。这很好,没有意识到这种获取测试步骤名称的简单方法。非常感谢。