Reputation: 614
I am trying to assert if an xml contains an xpath. For example the xpath is: //vmap:AdBreak[@timeOffset='00:00:20']
When I check it on https://www.freeformatter.com/xpath-tester.html it successfully returns an element.
However when I tried using below karate mechanism, it fails:
Given url "https://ray.mond.com/"
And header Content-Type = 'application/xml'
And path "vmap/vmap.xml"
When method GET
Then status 200
* print response
* xml resp = response
* def vmap = //vmap:AdBreak[@timeOffset='00:00:20']
* match resp contains vmap
The error is
xpath does not exist: //vmap:AdBreak[@timeOffset='00:00:20'] on response
Am I doing it the wrong way? I am trying to follow the docs here https://github.com/intuit/karate/blob/master/karate-junit4/src/test/java/com/intuit/karate/junit4/xml/xml.feature .
Thanks a lot!
Upvotes: 1
Views: 892
Reputation: 58058
Yes, XPath has some weird behavior at times. I'd appreciate if you can help troubleshoot and fix. This is not a priority for us as JSON is the most common case.
But here is your workaround:
* def vmap = /VMAP/AdBreak[@timeOffset='00:00:20']
Upvotes: 1