113
Views
3
Comments
Solved
Cannot read properties of undefined (reading 'click')
Application Type
Reactive
Platform Version
11.18.1 (Build 37905)

Hi All ,

Please help  me to solve this error . Error is coming due to this script .

Java script used in the logic is :  document.getElementsByClassName('popover-background-window')[0].click();

Can anyone help me where will I get the class name?

Regards,

Sohel 

2023-08-28 07-00-10
Paulo Torres
Champion
Solution

Hello,

I don't know the use case but you are trying to click somewhere is not in the DOM yet.

Add a timeout in your JS:

setTimeout(function() { document.getElementsByClassName('popover-background-window')[0].click(); }, 100);


If doesn't work let me know about the use case.

Regards

2025-10-16 10-02-51
Sohel Khan

Thanks a lot @Paulo Torres  . Its working fine now . Can you please brief me  the root cause for this error and how you solved.

2023-08-28 07-00-10
Paulo Torres
Champion

I'm glad to help you :)

The problem is because you are trying to click somewhere that you son't have in your DOM/not loaded yet. Maybe you are toggling between visible and hidden.

My script just add a timeout, so instead to click immediately, just will be clicked after 0.001 seconds. Normally it's enough to have the element in the DOM :)

Some learnings today :)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.