test(weekly): crosshair tests (#4273)

This commit is contained in:
Ibrahim authored and GitHub committed 2024-07-02 10:20:31 -04:00
1 parent 6faf3a17f9
commit 32762e6bce
9 files changed
+138 -1

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { Page } from "@playwright/test";
interface WindowWithMousePosition extends Window {
mouseX: number;
mouseY: number;
}
export const initilizeMousePositionTracker = async (page: Page) => {
const window = await page.evaluateHandle("window") as any;
await page.evaluate((window: WindowWithMousePosition) => {
window.mouseX = 0;
window.mouseY = 0;
window.addEventListener("mousemove", (event) => {
window.mouseX = event.clientX;
window.mouseY = event.clientY;
});
}, window);
}
export const getMousePosition = async (page: Page) => {
const window = await page.evaluateHandle("window") as any;
return await page.evaluate((window: WindowWithMousePosition) => {
return { x: window.mouseX, y: window.mouseY };
}, window);
}