Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I used function click on the chrome console I get undefined

I am using a xpath trying to click but I get undefined.

$x('//*[@id="form-container"]/ul/li[8]/div/div[2]/a')[0].click();

You can click manually is there any other way that I can click on the console and I tried $x('//*[@id="form-container"]/ul/li[8]/div/div[2]/a').click() but does not work.

like image 750
Rafa Soto Chan Avatar asked Oct 12 '25 04:10

Rafa Soto Chan


1 Answers

You can create a click event and dispatch it on a html element

var evt = new Event("click", {"bubbles":true});
document.addEventListener("click",e=>console.log("clicked",e));
document.dispatchEvent(evt);
like image 186
HMR Avatar answered Oct 14 '25 18:10

HMR