23 Jun 2022 09:10 PM
This works great, except in the case of the load time of one of the test url's takes to long and puts the javascript over the 60 second mark. It will then fail without performing all the tests and won't get to the main point of the test to fetch that url which sets a flag. As you can see I have a sleep function to allow it to wait 10 seconds between tests. The average load time of that page is 77ms. Now if the page takes 5 seconds to load we will hit the 60 second timeout of javascript funtion. Is there a way to catch that timeout?
Thanks
Tom
{
"configuration": {
"chromiumStartupFlags": {
"disable-web-security": false
},
"device": {
"orientation": "landscape",
"deviceName": "Desktop"
}
},
"type": "clickpath",
"version": "1.0",
"events": [{
"type": "javascript",
"wait": {
"waitFor": "next_event"
},
"description": "EBSAccessScript",
"javaScript": " function UrlExists(url) {\r\n var http = new XMLHttpRequest();\r\n http.open('HEAD', url, false);\r\n http.send();\r\n if (http.status == 200)\r\n return true;\r\n else\r\n return false;\r\n }\r\n\r\n\r\n\r\n function sleep(milliseconds) {\r\n const date = Date.now();\r\n let currentDate = null;\r\n do {\r\n currentDate = Date.now();\r\n } while (currentDate - date < milliseconds);\r\n }\r\n\r\n for (let i = 0; i < 5; i++) {\r\n sleep(10000);\r\n if (!UrlExists(\"http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp\")) {\r\n if (i == 4) {\r\n fetch('https://test02.sonoco.com/mysfsvc-rint/common/set_downtime_status/DOWN/g5H37k');\r\n api.fail(\"MYSF has been set to downtime.\");\r\n }\r\n }\r\n }"
}, {
"type": "navigate",
"wait": {
"waitFor": "page_complete"
},
"description": "Loading of \"http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp\"",
"url": "http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp"
}]
}
Solved! Go to Solution.
24 Jun 2022 10:03 AM
Do you need to wait 10s between each fetch? Could this be lowered? Alternatively, could you run the same but as an HTTP Monitor, running the check every minute but on 6 locations (so the url would be checked every 10s) and then use the outage handling settings to handle how many consecutive failures you are interested in.
Another alternative might be to join the HTTP Monitor Advanced Settings preview a this would provide the option of running an HTTP Monitor with upto 5 minute timeout.