Print the request step response in groovy script step using variable

时间:2016-08-31 16:51:13

标签: groovy soapui

I have a requirement in which I need to print XML response in Groovy Script test step

  • Name of SOAP Request test step is Licensed

When I write

log.info context.expand('${Licensed#Response}')

I get right response

But I have a requirement where user is not aware of the code

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

log.info context.expand($'{requestname"#Response}')

I don't get valid response

I want to declare a variable and use and print xml response

1 个答案:

答案 0 :(得分:0)

Here is what you need in order use the step name as parameter / variable. You have a trivial error in your code snippet.

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

Hope this resolves your issue.