无法将 groovy 参数值传递给 soapUI 请求 xml
can not pass groovy parameter value to soapUI request xml
想要将 bankaTalimatNo 参数传递给来自 groovy 脚本的以下请求。
我创建了一个名为 bankaTalimatiNo.
的测试用例级别 属性
在 groovy 脚本中,我迭代了一个数组以设置值 属性 值正确,但生成的请求不会与 属性 值并行更改。
实现此目的的正确 XML 表达式应该是什么?
提前致谢
<soapenv:Header/>
<soapenv:Body>
<wso:kurumOdemesiSorgulaRequest>
<wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo>
</wso:kurumOdemesiSorgulaRequest>
</soapenv:Body>
</soapenv:Envelope>
而groovy脚本如下
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("maliye")
testSuite = project.getTestSuiteByName("TestSuite 1");
testCase = testSuite.getTestCaseByName("TestCase 1");
testStep=testCase.testSteps["SOAP Request1"]
File file = new File("C:/temp/test.txt")
file.write "This is the first line\n"
def String[] talimatNoArray = [
"3"
];
talimatNoArray.eachWithIndex{talimatNo, i->
testCase.setPropertyValue("bankaTalimatiNo" , "${talimatNo}");
log.info "aaa"+ testCase.getPropertyValue("bankaTalimatiNo");
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
context.bankaTalimatiNo=testStep.getPropertyValue("bankaTalimatiNo");
def responseHolder=testStep.getPropertyValue("response");
//Check if the response is not empty
assert responseHolder, 'Response is empty or null'
}
生成的请求始终相同,从不计算表达式
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wso="http://maliye.yte.bilgem.tubitak.gov.tr/odeme/kurumodemesi/server/wso">
> <soapenv:Header/> <soapenv:Body>
> <wso:kurumOdemesiSorgulaRequest>
> <wso:bankaTalimatiNo>${bankaTalimatiNo}</wso:bankaTalimatiNo>
> </wso:kurumOdemesiSorgulaRequest> </soapenv:Body> </soapenv:Envelope>
在请求中,更改为:
<wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo>
收件人:
<wso:bankaTalimatiNo>${#TestCase#bankaTalimatiNo}</wso:bankaTalimatiNo>
想要将 bankaTalimatNo 参数传递给来自 groovy 脚本的以下请求。 我创建了一个名为 bankaTalimatiNo.
的测试用例级别 属性在 groovy 脚本中,我迭代了一个数组以设置值 属性 值正确,但生成的请求不会与 属性 值并行更改。
实现此目的的正确 XML 表达式应该是什么? 提前致谢
<soapenv:Header/> <soapenv:Body> <wso:kurumOdemesiSorgulaRequest> <wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo> </wso:kurumOdemesiSorgulaRequest> </soapenv:Body> </soapenv:Envelope>
而groovy脚本如下
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("maliye")
testSuite = project.getTestSuiteByName("TestSuite 1");
testCase = testSuite.getTestCaseByName("TestCase 1");
testStep=testCase.testSteps["SOAP Request1"]
File file = new File("C:/temp/test.txt")
file.write "This is the first line\n"
def String[] talimatNoArray = [
"3"
];
talimatNoArray.eachWithIndex{talimatNo, i->
testCase.setPropertyValue("bankaTalimatiNo" , "${talimatNo}");
log.info "aaa"+ testCase.getPropertyValue("bankaTalimatiNo");
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
context.bankaTalimatiNo=testStep.getPropertyValue("bankaTalimatiNo");
def responseHolder=testStep.getPropertyValue("response");
//Check if the response is not empty
assert responseHolder, 'Response is empty or null'
}
生成的请求始终相同,从不计算表达式
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wso="http://maliye.yte.bilgem.tubitak.gov.tr/odeme/kurumodemesi/server/wso">
> <soapenv:Header/> <soapenv:Body>
> <wso:kurumOdemesiSorgulaRequest>
> <wso:bankaTalimatiNo>${bankaTalimatiNo}</wso:bankaTalimatiNo>
> </wso:kurumOdemesiSorgulaRequest> </soapenv:Body> </soapenv:Envelope>
在请求中,更改为:
<wso:bankaTalimatiNo>${Properties#bankaTalimatiNo}</wso:bankaTalimatiNo>
收件人:
<wso:bankaTalimatiNo>${#TestCase#bankaTalimatiNo}</wso:bankaTalimatiNo>