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
Solved! Go to Solution.
Hi Simona,
Can you provide more details why you need this? Can you describe scenario when regular .Click() method provided by TestComplete does not work?
P.S. https://support.smartbear.com/articles/testcomplete/embedding-scripts-into-web-pages/ might appear to be an inspiring reading...
That's not a TestComplete method, so you might want to look elsewhere for help. I found this on Google but there might be better resources.
Thanks @Marsha_R , I had already though to initialize a variable as a new "Event" (as in the example that you've linked), but Test Complete doesn't recognize the DOM "Event" class. When I run the test, the following Javascript runtime error is displayed: "ReferenceError: Event is not defined".
There could be some configurations to be done on the project, or something that could be referenced by the project, to have the DOM classes visible?
Hi Simona,
Can you provide more details why you need this? Can you describe scenario when regular .Click() method provided by TestComplete does not work?
P.S. https://support.smartbear.com/articles/testcomplete/embedding-scripts-into-web-pages/ might appear to be an inspiring reading...
Alex, Marsha, thanks a lot!
@simonaferrara were you able to solve this? If not, let's keep the community investigation going - please provide the info Alex is asking about. Thanks.
Thanks @AlexKaras, the link that you send me is an interesting topic, and it could be interesting also for future purposes. We will try to investigate and use this approach if needed.
Subject | Author | Latest Post |
---|---|---|