空手道从请求中获取一个变量
Karate get one variable from a request
Given request
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.openkm.com">
<soapenv:Header/>
<soapenv:Body>
<ws:login>
<!--Optional:-->
<user>TestUser</user>
<!--Optional:-->
<password>TestUser</password>
</ws:login>
</soapenv:Body>
</soapenv:Envelope>
"""
When soap action 'http://ws.openkm.com/OKMAuth/login'
Then status 200
* def token = //return
Result = response={soap:Envelope={={soap:Body={ns2:loginResponse={= {return=a866fb4f-47e 4-4895-ac13-2118b6c0 25c8},@={xmlns:ns2=ws.openkm.com}}}},@={xmlns:soap=schemas.xmlsoap.org/soap/envelope}}} , responseStatus=200, __loop=-1, responseCookies=null, token=a866fb4f-47e4-4895-ac13-2118b6c025c8}
我从一个请求中得到了这个回复。如何从正文中获取 'return' 或 'token'?
您似乎没有阅读 calling features 上的文档。除非你清楚它是如何工作的,否则我建议你根本不要使用 call
。
我(仍然)无法阅读您的回复 XML,所以我不能说 //return
是否真的为您提供了您想要的价值。假设它确实如此,您现在已将它分配给一个名为 result
的变量 RequestToken.feature
对。所以现在,试试这个:
# this result will again contain a variable 'result'
* def result = call creator
* def return = result.result
* print return
除非您仔细阅读文档,否则我帮不上什么忙。
Given request
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.openkm.com">
<soapenv:Header/>
<soapenv:Body>
<ws:login>
<!--Optional:-->
<user>TestUser</user>
<!--Optional:-->
<password>TestUser</password>
</ws:login>
</soapenv:Body>
</soapenv:Envelope>
"""
When soap action 'http://ws.openkm.com/OKMAuth/login'
Then status 200
* def token = //return
Result = response={soap:Envelope={={soap:Body={ns2:loginResponse={= {return=a866fb4f-47e 4-4895-ac13-2118b6c0 25c8},@={xmlns:ns2=ws.openkm.com}}}},@={xmlns:soap=schemas.xmlsoap.org/soap/envelope}}} , responseStatus=200, __loop=-1, responseCookies=null, token=a866fb4f-47e4-4895-ac13-2118b6c025c8}
我从一个请求中得到了这个回复。如何从正文中获取 'return' 或 'token'?
您似乎没有阅读 calling features 上的文档。除非你清楚它是如何工作的,否则我建议你根本不要使用 call
。
我(仍然)无法阅读您的回复 XML,所以我不能说 //return
是否真的为您提供了您想要的价值。假设它确实如此,您现在已将它分配给一个名为 result
的变量 RequestToken.feature
对。所以现在,试试这个:
# this result will again contain a variable 'result'
* def result = call creator
* def return = result.result
* print return
除非您仔细阅读文档,否则我帮不上什么忙。