0

I have seen many questions regarding how to achieve equivalent of physical click using Javascript. While those methods work in simple use-cases, I have come across many complex UIs where I am unable to achieve the result of a physical click using Javascript event.

To give an example, in outlook calendar, when creating a new event, clicking the description box expands it and shows extra UI buttons. I am unable to get this effect no matter how many combinations of different events I try.

description box of outlook calendar

My question is: is it theoretically always possible to achieve a real equivalent of physical click using Javascript? Or am I wasting my time on something which is not possible?

Context: I am trying it using Chrome extension's content scripts.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Cashif Ilyas
  • 1,619
  • 2
  • 14
  • 22
  • 1
    Theoretically possible always? Yes, if you can run JS first, but the logic you need to implement may be very difficult to figure out. – CertainPerformance May 19 '20 at 16:55
  • If the page doesn't check `isTrusted` property of the event then you can dispatch the event that's used by the page. Use devtools `Event listeners` panel to find out which event is used by the element (or its ancestor in case of *delegated events*), debug the page script or reverse-engineer it. If isTrusted has to be imitated then you'll have to override addEventListener and onXXX event setters in [page context](/a/9517879) at `document-start`. – wOxxOm May 19 '20 at 17:02

0 Answers0