I have a scenario to conditional wait for every 5 secs for max 1 min. And I have implemented it via polling using java.lang.Thread.sleep(), which is blocking the Threads and failing in my multithread project. How can I use something like karate.pause() in my normal karate feature functions? Note: I can't use "retry until" in my case.
This is the method I use for polling with Thread.sleep(),
* def checkForEventCompletion =
"""
function(arg) {
var poolTime = 5;
var counter = 1;
// should pool for every 5 seconds until it exceeds your input wait time
while (true) {
if( (counter*poolTime) > arg.maxWaitTime){
karate.log('Status Not yet Updated');
return EventStatus;
}
//Code to Fetch EventStatus
karate.log('Current Status->',EventStatus);
if (EventStatus == 'COMPLETED') {
karate.log('Status Verified, --Exiting--');
return true;
}
// pool every 5 seconds
java.lang.Thread.sleep(poolTime*1000);
counter++;
}
}
When I try to use karate.pause(), it fails with "invokeMember (pause) on com.intuit.karate.core.ScenarioBridge@4acb7ecc failed due to: Unknown identifier: pause".