I'm currently writing an e2e test case using Playwright with TypeScript. I want to get the data stored in Chartjs canvas. I found it's stored in the element's event listener handler and tried to access with the code below, however only getting { event: { isTrusted: false } } as result.
Here is the code I have tried:
const eventData = await page.evaluate(async () => {
return new Promise((resolve) => {
const canvas = document.querySelector("canvas");
canvas.addEventListener("mousemove", function captureEvent(event) {
canvas.removeEventListener("mousemove", captureEvent);
resolve({
event: event
});
});
const event = new MouseEvent("mousemove", {
clientX: 100,
clientY: 100,
bubbles: true,
cancelable: true,
});
canvas.dispatchEvent(event);
});
});
console.log(eventData);
And here is the handler I'm trying to access, I found it in browser inspect's element event listeners:

Wonder is there any possible way to achieve what I'm trying to do, thank you!