# browser monitor - js help

**URL:** <https://community.dynatrace.com/t/browser-monitor-js-help/35628>\
**Category:** Synthetic Monitoring\
**Tags:** browser-monitors, javascript, synthetic-monitoring\
**Created:** [June 28, 2022, 1:07pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628 "2022-06-28T13:07:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan\_rose](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jordan\_rose](https://community.dynatrace.com/u/jordan_rose)\
**Post date:** [June 28, 2022, 1:07pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628/1 "2022-06-28T13:07:46Z")

</div>

Hi All, trying to get some help on using a js event in my browser monitor. I am attempting to capture a variable on the screen and use it later but the step ends up failing with “js execution took too long”.

I have tried several different wait times. With the “wait 5 seconds” option it sits for much longer than 5 seconds before erroring out.

I logged into the page \> dev tools \> right click on the element and chose 'copy js path", then used it in the query selector. I am not 100% about the target window but we never open a new tab/window so left as default.

Any help with this is much appreciated as I am not very html savvy.

 ![jordan_rose_0-1656422091485.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/d/3d4f57118e616c8740cea1658f04e73663768aab.png)

![jordan_rose_1-1656422112448.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/f/cf9d82a7cbc6d59742cd7215adcae4f25c1d2ff2.png)

---

<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 28, 2022, 1:46pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628/2 "2022-06-28T13:46:32Z")

</div>

Can you try adding the window? If it’s the initial one it will be window[0]. Then, can you also print the value of otp, after setting it,&nbsp; to the vuc-http-custom.log using

api.info("otp: " + otp);

Hopefully, that will give us a clue as to what’s going on .

---

<div class="post-metadata">

**Author:** ![jordan\_rose](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jordan\_rose](https://community.dynatrace.com/u/jordan_rose)\
**Post date:** [June 28, 2022, 3:39pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628/3 "2022-06-28T15:39:11Z")

</div>

Hi Hannah, thanks for reply. I notice you cant actually specify&nbsp;window[0] as it just auto resets it back to “optional”. I guess it assumes that by default.

I added the logging line but it doesnt seem to be writing anything there. The log is empty on both of the synthetic AGs for this env.

---

<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 28, 2022, 3:50pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628/4 "2022-06-28T15:50:53Z")

</div>

OK, thanks. I think this would be best looked at directly either through chat or a support ticket so we can check your whole script and logs,

---

<div class="post-metadata">

**Author:** ![jordan\_rose](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jordan\_rose](https://community.dynatrace.com/u/jordan_rose)\
**Post date:** [June 28, 2022, 5:52pm UTC](https://community.dynatrace.com/t/browser-monitor-js-help/35628/5 "2022-06-28T17:52:17Z")

</div>

Hi Hannah, adding inner.HTML to the end fixed the issue and I can see the log now.

var otp = document.querySelector(“#content \> div \> form \> fieldset \> div:nth-child(3) \> div \> p:nth-child(3) \> b”).innerHTML;

Thanks for the response/help!
