# browser click path with javascript as the first function

**URL:** <https://community.dynatrace.com/t/browser-click-path-with-javascript-as-the-first-function/35587>\
**Category:** Synthetic Monitoring\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [June 23, 2022, 8:10pm UTC](https://community.dynatrace.com/t/browser-click-path-with-javascript-as-the-first-function/35587 "2022-06-23T20:10:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tchaffee](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@tchaffee](https://community.dynatrace.com/u/tchaffee)\
**Post date:** [June 23, 2022, 8:10pm UTC](https://community.dynatrace.com/t/browser-click-path-with-javascript-as-the-first-function/35587/1 "2022-06-23T20:10:42Z")

</div>

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.&nbsp; 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.&nbsp; As you can see I have a sleep function to allow it to wait 10 seconds between tests.&nbsp; The average load time of that page is 77ms.&nbsp; Now if the page takes 5 seconds to load we will hit the 60 second timeout of javascript funtion.&nbsp; 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\](http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp%5C)”)) {\r\n if (i == 4) {\r\n fetch(‘[https://test02.sonoco.com/mysfsvc-rint/common/set\_downtime\_status/DOWN/g5H37k](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\](http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp%5C)””,  
“url”: “[http://erpprod.sonoco.com/OA\_HTML/AppsLocalLogin.jsp](http://erpprod.sonoco.com/OA_HTML/AppsLocalLogin.jsp)”  
}]  
}

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [June 24, 2022, 9:03am UTC](https://community.dynatrace.com/t/browser-click-path-with-javascript-as-the-first-function/35587/2 "2022-06-24T09:03:25Z")

</div>

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.&nbsp;  
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.
