karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.33k stars 1.95k forks source link

Parsing xml response in Karate #1397

Closed rohit1212s closed 3 years ago

rohit1212s commented 3 years ago

I want to parse my xml response and assert some value but seems like karate doesn't support relative path in xml. when I give absolute path ex:- Envelope/Body/ns3:GetRevisionDetailsResponse/ns3:revision/ns3:revisionDetail/ns3:calculatedCost[1]/ns5:amount[1]/ns4:amount[1]/text()[1] == '#string' . It works but for this small xml I can give absolute but for huge xml file if I write the relative path it doesn't find ex:- //calculatedCost[1]/ns5:amount[1]/ns4:amount[1]/text()[1] == '#string' . Also if I want to validate response like if the response is Big integer or Big decimal . I am not able to suceed. see the below example:-

EUR #big integer #big decimal #string 0.00000 BG-ING F SUS ACT RC I am really strugling with this. I suggested in my team that Karate can be so useful in order to create a automation framework for soap api testing and they are ready to implement but I amstrugling in soap xml assertions. Please suggest a solution for this.
ptrthomas commented 3 years ago

@rohit1212s please ask on stack overflow, actually if you search you will get answers: https://stackoverflow.com/search?q=%5Bkarate%5D+xpath

Cpens commented 10 months ago

Hi,

I am looking to compare soap XML response with REST JSON response. The reason for ask is i have legacy app that generated soap xml response but as per new standards we are converting to REST JSON, is there a function avail in karate? I have tried xmlpath and xpath options and it didn't work so not sure what i am doing wrong?