-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-browser.js
More file actions
59 lines (48 loc) · 1.9 KB
/
Copy pathtest-browser.js
File metadata and controls
59 lines (48 loc) · 1.9 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Simple script to test if the page loads and capture console
const puppeteer = require('puppeteer');
(async () => {
try {
console.log('Launching browser...');
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// Capture console messages
const logs = [];
page.on('console', msg => {
const type = msg.type();
const text = msg.text();
logs.push({ type, text });
console.log(`[${type.toUpperCase()}] ${text}`);
});
// Capture errors
page.on('pageerror', error => {
console.log(`[PAGE ERROR] ${error.message}`);
logs.push({ type: 'error', text: error.message });
});
console.log('Navigating to http://localhost:3000...');
await page.goto('http://localhost:3000', { waitUntil: 'networkidle0', timeout: 10000 });
// Wait a bit for React to render
await page.waitForTimeout(2000);
// Get current URL
const url = page.url();
console.log(`Current URL: ${url}`);
// Get page title
const title = await page.title();
console.log(`Page title: ${title}`);
// Check if there's content
const bodyText = await page.evaluate(() => document.body.innerText);
console.log(`Body text length: ${bodyText.length}`);
console.log(`Body text preview: ${bodyText.substring(0, 200)}`);
// Take screenshot
await page.screenshot({ path: 'debug-screenshot.png', fullPage: true });
console.log('Screenshot saved to debug-screenshot.png');
// Summary
console.log('\n=== SUMMARY ===');
console.log(`Total console messages: ${logs.length}`);
console.log(`Errors: ${logs.filter(l => l.type === 'error').length}`);
console.log(`Warnings: ${logs.filter(l => l.type === 'warning').length}`);
await browser.close();
} catch (error) {
console.error('Failed:', error.message);
process.exit(1);
}
})();