[英]Def variable with "string" XML in Karate
我的问题与另一个现有的问题相似(对此感到抱歉)但有所不同...我的 XML 输入具有字符串格式:
* def token = '123456'
* def payload =
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>
<token>#(token)</token>
</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
"""
* print payload
哪个打印:
[print] <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>
<token>#(token)</token>
</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
你能帮我吗?
我尝试了给定的解决方案,但也不起作用:
def num = '<num>' + random_num(5) + '</num>'
[print] <num>39631</num>
Given request:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1>
<ns1:XML_INPUT>
<testone>00</testone>
<numtwo>267</testtwo>
#(num)
<testthree>267</testthree>
</ns1:XML_INPUT>
</ns1>
</soap:Body>
</soap:Envelope>
尝试:
* def token = '<token>' + 123456 + '</token>'
* def payload =
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.com">
<soapenv:Header/>
<soapenv:Body>
<ws:isValid>#(token)</ws:isValid>
</soapenv:Body>
</soapenv:Envelope>
"""
并阅读文档: https://github.com/intuit/karate#embedded-expressions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.