空手道 - 如何将XML响应保存为XML以后使用?
我正在发送一个请求,该请求返回XML中的响应。 当响应首先回来时,我可以从XML提取值,如下示例所示。
* def balanceAmount = $response/Envelope/Body/balanceAmount/amount
And print balanceAmount
但是,我然后发送另一个请求,以使上述响应被覆盖 - 因此我需要将其保存为XML-因此我可以在测试中以后回想起这些值。
我已经尝试了许多方法来完成此操作,包括以下内容:
* def xmlResponse = $response
* def xmlResponse = response
* xml xmlResponse = $response
* xml xmlResponse = response
但是我无法像以前那样访问XML响应中的值。
我已经尝试过这些:
* def balanceAmount = xmlResponse/Envelope/Body/balanceAmount/amount
And print balanceAmount
* def balanceAmount = $xmlResponse/Envelope/Body/balanceAmount/amount
And print balanceAmount
以上都没有作用。
那么,如何将XML响应保存为XML,以便在发送其他请求后在测试中以稍后从其中提取值?
I am sending a request that returns a response in XML.
When the response first comes back I can extract values from the XML as shown in the example below.
* def balanceAmount = $response/Envelope/Body/balanceAmount/amount
And print balanceAmount
However I then send another request so the above response is overwritten - so I need to save it as XML - so I can recall the values later on in the test.
I have tried many ways of doing this including the following:
* def xmlResponse = $response
* def xmlResponse = response
* xml xmlResponse = $response
* xml xmlResponse = response
But I can no longer access the values in the XML response like I could earlier.
I've tried these:
* def balanceAmount = xmlResponse/Envelope/Body/balanceAmount/amount
And print balanceAmount
* def balanceAmount = $xmlResponse/Envelope/Body/balanceAmount/amount
And print balanceAmount
None of the above works.
So how can I save the xml response as xml so I can extract values from it later on in the test after sending a different request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它对我来说很好,这里可以尝试此独立功能:
如果您仍然卡住-issue“ rel =“ nofollow noreferrer”> https://github.com/karatelabs/karate/wiki/how-to-to-submit-an-sissue
It works fine for me, here try this stand-alone feature:
If you are still stuck, follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue