I currently have the below retry statement:
* retry until karate.xmlPath(response, '//ResultCount') == 1 && karate.xmlPath(response, '//Code') == 0
If the retry fails, this message is printed: 'too many retry attempts: 10'
The issue we are facing is: we can't tell which part of the retry condition failed. Does anyone have any suggestions? Any help is appreciated!
Few things I have tried:
* retry until karate.xmlPath(response, '//ResultCount') == 1
* retry until && karate.xmlPath(response, '//Code') == 0
Even though the first condition passed and the second failed, the report shows the failure at the soap action, so I still cannot tell which condition failed:
[passed] >> * retry until karate.xmlPath(response, '//ResultCount') >= 1
[passed] >> * retry until karate.xmlPath(response, '//Code') == 0 [it actually failed here]
[failed] >> * soap action 'http://mywebservice' too many retry attempts: 5
My suggestion is define a function - and then use that, so it helps break down things and debug. Also I'm showing an alternate possibly more robust way to grab the response. For example:
* def isValid =
"""
function() {
var resp = karate.get('response');
karate.log('testing response:', resp);
return karate.xmlPath(resp, '//ResultCount') == 1;
}
"""
# some code
* retry until isValid()
Also refer to this answer for more ideas: https://stackoverflow.com/a/55823180/143475