For one of our DELETE request time taken is more than 30 sec. Sometimes tests fails if it takes more than 30 sec. I need to add wait for response until certain GET call passes. I tried below code. But I wants to check some condition in GET call then I wants to assert for DELETE call.
Feature:
Background:
* def waitUntil =
"""
function(x) {
while (true) {
var result = karate.call('classpath:ic/feature/soap/Common/getApplicationsList.feature');
var res = result.response;
karate.log('poll response in side java script', res.integration.serviceData.applicationsList.WmSOAPProvider['MyKarateSoap']);
karate.log('Actual responseis in jacva script ---> ', res.integration.serviceData.applicationsList.WmSOAPProvider)
var local = res.integration.serviceData.applicationsList.WmSOAPProvider['MyKarateSoap'];
karate.log('local value is--->' +local)
karate.log('res is ----->' +res)
if (res.integration.serviceData.applicationsList.WmSOAPProvider['MyKarateSoap'] == null) {
karate.log('condition satisfied, exiting');
return;
}
karate.log('sleeping in else block');
// uncomment / modify the sleep time as per your wish
java.lang.Thread.sleep(3000);
}
}
"""
Scenario: delete soap application
Given url appServer
And path '/integration/rest/application/WmSOAPProvider/' +'MyKarateSoap'
And header Accept = 'application/json'
And header Content-Type = 'application/json'
And header X-CSRF-TOKEN = lresult.response.csrfToken
* cookie JSESSIONID = lresult.responseCookies.JSESSIONID.value
* cookie route = lresult.responseCookies.route.value
When method delete
* call waitUntil 200
In the above code 'waitUntil' is called only when the 'delete' call is passed.
But I wants to call 'waituntil' only when the DELETE call response is failed/took more than 30 sec
I followed How to retry a request until i get a valid dynamically generated value in response using karate dsl
But not much helpful