When I use contentscript
click a button that make by Javascript on the website's page.
element.click()
I face the same problem: click is not a function, just like this:
Can't click a button using a Chrome extension, but I can in the developer tools
but, I can manual click the button to do something, just like download a file.
Thanks to the author, I got the solution:
var x =document.getElementById("someelement");
x.addEventListener('click',function myClick() {
//here keep empty is ok. no need write anything
});
await sleep(10000);
x.click(); //this lead to the element 's original activity, just like download something....
Now, everything is ok, my question is: why? why this can solve the problem?
BTW, the question that I quote is not duplicate, because that is treat as duplicate, so I can not ask/answer this on the question directly.