1

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:

  • I can't add a print statement for the ResultCount and Code because it won't print if the retry fails, which makes sense because it's failing at the soap action
  • I tried separating the && into two distinct lines, but that did not help, see below:
* 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
General Grievance
  • 4,555
  • 31
  • 31
  • 45
David A
  • 37
  • 3

1 Answers1

2

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

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248