使用变量在groovy脚本步骤中打印请求步骤响应

使用变量在groovy脚本步骤中打印请求步骤响应,groovy,soapui,Groovy,Soapui,我需要在Groovy脚本测试步骤中打印XML响应 SOAP请求测试步骤的名称已获得许可 当我写作时 log.info context.expand('${Licensed#Response}') 我得到了正确的回答 但我有一个用户不知道代码的要求 def requestname=Licensed //user will enter request name here log.info context.expand($'{requestname"#Response}') 我没有得到有

我需要在
Groovy脚本
测试步骤中打印XML响应

  • SOAP请求测试步骤的名称已获得许可
当我写作时

log.info context.expand('${Licensed#Response}')
我得到了正确的回答

但我有一个用户不知道代码的要求

def requestname=Licensed //user will   enter request name here

log.info context.expand($'{requestname"#Response}')
我没有得到有效的答复


我想声明一个变量,并使用和打印xml响应,这里是使用步骤名称作为参数/变量所需的内容。您的代码片段中有一个小错误

//You missed quotes  
def requestname='Licensed'   
//Your were using quotes incorrectly   
log.info context.expand('${'+requestname+'#Response}')

希望这能解决您的问题。

以下是使用步骤名称作为参数/变量所需的内容。您的代码片段中有一个小错误

//You missed quotes  
def requestname='Licensed'   
//Your were using quotes incorrectly   
log.info context.expand('${'+requestname+'#Response}')

希望这能解决您的问题。

log.info context。expand(${requestname”+#Response“}”)我还尝试了def requestfull=Licensed#Response log.info context。expand(${requestfull})也不起作用。正确的响应代码是log.info context。expand(${Licensed#Response})您的意思是说请求步骤名称被放入变量?log.info context。expand(${requestname”+#Response“}”)我还尝试了def requestfull=Licensed#Response log.info context。expand(${requestfull})也不起作用。正确的响应代码是log.info context。expand(${Licensed#Response})你的意思是说请求步骤名称被放入变量中了吗?@gauriapardh,很高兴知道答案是有帮助的。如果您能花点时间访问@Gauriaparrah,我将不胜感激,很高兴知道答案是有帮助的。如果您能抽出一点时间来谈谈,我将不胜感激