Forum Discussion

simonaferrara's avatar
simonaferrara
Frequent Contributor
5 years ago
Solved

The dispatchEvent browser method doesn't work

Hi all,

 

in a web test (I'm using JavaScript), I want to use the "dispatchEvent" browser method to dispatch a browser-specific event or a custom event created on the browser.

 

As simple examples (just to try how to use the method), I've tried to dispatch a "pointerdown" and then a "pointerup" after a delay, or I to do a click on a button using this dispatchEvent method.

 

I've tried this code:

   canvas.dispatchEvent("pointerdown");
   Delay(600);
   canvas.dispatchEvent("pointerup");

 

and 

  button.dispatchEvent("click");

 

But it doesn't work. Nothing appens in the browser, as if the browser doesn't receive the event.

 

How can I use this method? Can you please explain me with some examples?

 

Thanks

Simona