2016-08-31 94 views
1

我在我需要打印使用打印在常規腳本步驟的請求步驟響應變量

  • SOAP請求測試步驟的名稱被許可在Groovy Script測試步驟XML響應的要求

當我寫

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

我馬上響應

但是我有一個要求,其中用戶不知道該代碼

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

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

的我沒有得到有效的響應

我要聲明一個變量,使用和打印XML響應

+0

log.info上下文。 ($'{requestname'+#Response「}') –

+0

此外,我試圖def requestfull = Licensed#響應log.info context.expand($'{requestfull}),這也不起作用 –

+0

早些時候正確的響應代碼是日誌。 info context.expand('$ {Licensed#response}') –

回答

0

這裏是你需要使用步驟名稱作爲參數/變量。你的代碼片段中有一個微不足道的錯誤。

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

希望這可以解決您的問題。

+0

非常感謝你的工作 –

+0

@GauriAparadh,很高興知道答案是有幫助的。我將不勝感激,如果你花一點時間[接受它作爲答案](http://stackoverflow.com/help/someone-answers) – Rao