Files

42 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser',
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
page.on('console', msg => console.log('PAGE CONSOLE:', msg.text()));
page.on('pageerror', err => console.log('PAGE ERROR:', err.message));
await page.goto('http://localhost:8765', { waitUntil: 'networkidle0' });
// Click start button
await page.click('.choice-btn');
await page.waitForTimeout(500);
// Try to make a choice in child event
const buttons = await page.$$('.choice-btn');
console.log('Child event buttons:', buttons.length);
if (buttons.length > 0) {
await buttons[0].click();
await page.waitForTimeout(500);
}
// Check what happened
const title = await page.$eval('#eventTitle', el => el.textContent);
const age = await page.$eval('#age', el => el.textContent);
console.log('After first choice - Title:', title, 'Age:', age);
const buttons2 = await page.$$('.choice-btn');
console.log('Buttons after first choice:', buttons2.length);
if (buttons2.length > 0) {
const texts = await Promise.all(buttons2.map(b => b.evaluate(el => el.textContent)));
console.log('Button texts:', texts);
}
await browser.close();
})();