dom.window.document.querySelector("a").dispatchEvent(new dom.window.MouseEvent("click"));
However, it seems when I add the dispatchEvent, I receive the following error:
TypeError: Cannot read properties of null (reading 'dispatchEvent')
at Timeout._onTimeout (/media/user/SanDiskSDXC/pushbot/torproject.org/metrics.js:42:66)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Node.js v17.4.0
Command exited with non-zero status 1
How does one call an asynchronous page, await for the response, and instantiate a click on the desired anchor tag to access the desired results?
Thank you for your assistance.
Respectfully,
Gary
All:
It seems the dom.window.MouseEvent("click") requires the { bubbles: true } attribute in this instance.
Changed dispatchEvent from:
dom.window.document.querySelector("a").dispatchEvent(new dom.window.MouseEvent("click"));
Changed dispatchEvent to:
dom.window.document.querySelector("a").dispatchEvent(new dom.window.MouseEvent("click", { bubbles: true }));
Now, I am able to programmatically click-through each anchor tag outputting the desired results to the console (all within the ~1 minute asynchronous request).