Once I send GET request , I am able to get 200 OK. In response body, there is a key, consider that is "field_name". Currently "field_name" value is "start".After some time, value is changes to stop.
Expected O/P : want to run it till i do not get the "field_name":"stop" in response body.
How about using while
loop, perform GET
request inside, get the status and put the Thread
to sleep?
String field_name = "start";
while (field_name.equals("start")) {
try {
Thread.sleep(500);
} catch (InterruptedException ignore) {
}
Response response = when().get("my url").then().extract().response();
field_name = response.jsonPath().getString("path.to.field_name");
}
In the above code, I assumed that field_name
is start
.
The loop begins, we wait for 500 milliseconds and after that time, we perform GET
request, extract its response and get the field_name
value.
If the field_name
value equals stop
then the loop will no longer be executed. If the loop equals start
then we wait for another 500 milliseconds, perform GET
, get the status etc...
Hope it helps!