Reputation: 391
I used following option
* def sleep =
"""
function(seconds){
for(i = 0; i <= seconds; i++)
{
java.lang.Thread.sleep(1*1000);
karate.log(i);
}
}
"""
* call sleep 10
But I want to understand if there is a better in-built way to do the same. Also want to know if static wait can be added
Upvotes: 2
Views: 16239
Reputation: 58058
I think what you are doing is fine. Search for "sleep" in the readme you will find this:
* def sleep = function(millis){ java.lang.Thread.sleep(millis) }
* sleep(1000)
The answer to the second part of your question is hooks: https://github.com/intuit/karate#hooks
I would NEVER do this, but as an example if you do * java.lang.Thread.sleep(1000)
in the Background
- it will sleep before each `Scenario.
EDIT - please look at the RuntimeHook
for advanced use-cases: https://stackoverflow.com/a/59080128/143475
Upvotes: 8