Can you tell me why the button click doesn't work in executeScript?
Here is an example
//****************************
func :=
function ckickElem() {
let sub = document.querySelectorAll(''[data-testid="trap-drawer"]'');
if(sub[0] != undefined) {
console.log(sub[0].childNodes[1]);
sub[0].childNodes[1].click();
}
}
ckickElem();
wbBrowser.ExecuteScript(func);
//************************
sub[0].childNodes[1] - exists
This is one example.
Everything is working fine through the developer's console
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Click doesn't work in JS
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Click doesn't work in JS
Hi,
I just checked this issue in the MiniBrowser demo.
I loaded this forum and I selected the menu option "Execute JavaScript..." with the following code :
The "Remember me" checkbox at the bottom has an id value of "autologin" and it was checked after executing that code.
Perhaps your web page detects if an event was initiated by the user :
https://stackoverflow.com/questions/29798010/detect-whether-an-event-is-triggered-by-user-and-not-programmatically
I just checked this issue in the MiniBrowser demo.
I loaded this forum and I selected the menu option "Execute JavaScript..." with the following code :
Code: Select all
document.getElementsByName('autologin')[0].click();
Perhaps your web page detects if an event was initiated by the user :
https://stackoverflow.com/questions/29798010/detect-whether-an-event-is-triggered-by-user-and-not-programmatically
-
- Posts: 2
- Joined: Mon May 12, 2025 9:45 am
Re: Click doesn't work in JS
The script is triggered via the developer's console, so I believe that the page does not take into account who is performing the click.