-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppeteer_test.js
More file actions
28 lines (23 loc) · 927 Bytes
/
Copy pathpuppeteer_test.js
File metadata and controls
28 lines (23 loc) · 927 Bytes
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
import puppeteer from 'puppeteer';
(async () => {
const browser = await puppeteer.launch({ headless: 'new', args: ['--no-sandbox'] });
const page = await browser.newPage();
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('pageerror', error => console.log('PAGE ERROR:', error.message));
page.on('requestfailed', request =>
console.log('REQUEST FAILED:', request.url(), request.failure()?.errorText)
);
try {
await page.goto('http://localhost:5173', { waitUntil: 'networkidle2', timeout: 10000 });
console.log("Page loaded successfully.");
const text = await page.evaluate(() => document.body.innerText);
if (text.includes('Connecting')) {
console.log('Connecting text found on page.');
} else {
console.log('No Connecting text found.');
}
} catch (err) {
console.log("Error loading page:", err);
}
await browser.close();
})();