-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-with-logs.js
More file actions
75 lines (60 loc) · 2.23 KB
/
Copy pathtest-with-logs.js
File metadata and controls
75 lines (60 loc) · 2.23 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Test Extension with Console Logs Visible
*/
const puppeteer = require('puppeteer');
const path = require('path');
const EXTENSION_PATH = path.join(__dirname, 'dist');
const TEST_URL = 'https://www.amazon.de/-/en/AlloverPower-E61-Group-Head-Coffee/dp/B0BNQ66ZN1';
async function testWithLogs() {
console.log('🚀 Testing extension with full console logs...\n');
const browser = await puppeteer.launch({
headless: false,
args: [
`--disable-extensions-except=${EXTENSION_PATH}`,
`--load-extension=${EXTENSION_PATH}`,
'--no-sandbox',
],
});
const page = await browser.newPage();
// Capture ALL console logs
const logs = [];
page.on('console', msg => {
const text = msg.text();
logs.push(text);
console.log('📝', text);
});
await page.goto(TEST_URL, { waitUntil: 'networkidle2', timeout: 30000 });
// Handle cookies
try {
const acceptButton = await page.waitForSelector('#sp-cc-accept, button[data-action="accept"], input[name="accept"]', { timeout: 3000 });
if (acceptButton) {
console.log('🍪 Accepting cookies...');
await acceptButton.click();
await new Promise(resolve => setTimeout(resolve, 2000));
}
} catch (e) {
console.log('⚠️ No cookie dialog found');
}
// Wait for widget
console.log('\n⏳ Waiting for extension widget...\n');
await page.waitForSelector('.amazon-returns-ext__widget', { timeout: 10000 });
const widgetText = await page.evaluate(() => {
const widget = document.querySelector('.amazon-returns-ext__widget');
return widget ? widget.innerText : null;
});
console.log('\n' + '═'.repeat(60));
console.log('📦 WIDGET CONTENT');
console.log('═'.repeat(60));
console.log(widgetText);
console.log('═'.repeat(60));
console.log('\n' + '═'.repeat(60));
console.log('📋 EXTENSION LOGS SUMMARY');
console.log('═'.repeat(60));
const extensionLogs = logs.filter(log => log.includes('[Amazon Returns Extension]'));
extensionLogs.forEach(log => console.log(log));
console.log('═'.repeat(60));
console.log('\n✅ Test complete - browser stays open for 10 seconds');
await new Promise(resolve => setTimeout(resolve, 10000));
await browser.close();
}
testWithLogs().catch(console.error);