-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright-debug.cjs
More file actions
41 lines (33 loc) · 1.11 KB
/
playwright-debug.cjs
File metadata and controls
41 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { chromium } = require("playwright");
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
page.on("console", (msg) => {
console.log("[BROWSER]", msg.text());
});
console.log("Navigating to http://localhost:5178");
await page.goto("http://localhost:5178", { waitUntil: "load" });
// Wait for loading
await page.waitForFunction(
() => !document.body.innerText.includes("Loading Game Assets..."),
{ timeout: 30000 },
);
console.log("Assets done.");
for (let i = 0; i < 40; i++) {
const txt = await page.evaluate(() => document.body.innerText);
console.log(`[STATE ${i}] DOM TEXT: ${txt.replace(/\n/g, " | ")}`);
// Find the React container and click it
await page.evaluate(() => {
const evt = new MouseEvent("click", {
bubbles: true,
cancelable: true,
view: window,
});
document.querySelector("div").dispatchEvent(evt);
// Also just click absolutely everything
document.body.click();
});
await page.waitForTimeout(1000);
}
await browser.close();
})();