16 Dec 2019 05:05 AM
Hello,
I have a HTTP monitor use case where I would like to wait/sleep a few seconds between step 1 and 2
Is it possible to add in pre/post execution scripts kind of sleep(### seconds) or something equivalent ?
Thanks.
Solved! Go to Solution.
16 Dec 2019 08:25 AM
You can use JS I think:
you can execute post execution script for the first step which for example will do:
setTimeout(function () {
//you can paste some code here if you need
}, 5000);
I've never tested it, but should be fine 🙂
Sebastian
16 Dec 2019 08:41 AM
Thanks @Sebastian K., unfortunately it does not work. I tried something equivalent already (assuming we might be able to execute generic JS script) but it failed.
When I paste your content in a post-execution script, I get the following in log:
Post script execution failed due to: ReferenceError: "setTimeout" is not defined. (script#1)
16 Dec 2019 08:50 AM
Ok you're right. Here are possibilities you have:
I don't see anything that can be handy here.
As a really dirt workaround may be creating some page with setTimeout set that you may use as request in the middle which will takes amount of time defined in query parameter.
Sebastian
16 Dec 2019 08:52 AM
yes, me too. I reviewed this documentation already. That is why I posted on this forum. I was hoping for some hidden trick.
thanks anyway for your help.
16 Dec 2019 09:32 AM
Hi guys
Long shot but you should give it a try and use browser test where you can add wait after step and run JavaScripts.
HTH
Yos
16 Dec 2019 10:53 AM
unfortunately not for this specific use case as I am testing an API
13 Jan 2020 08:23 AM
Would a dummy API call to sleep for a given time solve your problem? For example, the postman echo service has such endpoint if you don't want to create your own.
This URL will, for example, wait 2 seconds between ending with a response:
https://postman-echo.com/delay/2
13 Jan 2020 12:30 PM
This is an interesting approach. Although I would prefer to avoid being dependent on a 3rd party API, I will definitely consider your idea.
Thanks a lot.
13 Jan 2020 12:59 PM
Agreed, but this is just an example. Sure you can deploy such API endpoint in your environment and it will be definitely the most simple one service you will have :-).