Trying to run headless: false in playwright 1.38 gives error: page closed
Full error: /home/path/node_modules/playwright-core/lib/server/chromium/crPage.js:377 this._firstNonInitialNavigationCommittedReject(new Error('Page closed')); ^
Error: Page closed at CRSession.<anonymous> (/home/path/node_modules/playwright-core/lib/server/chromium/crPage.js:377:54) at Object.onceWrapper (node:events:628:28) at CRSession.emit (node:events:526:35) at /home/path/node_modules/playwright-core/lib/server/chromium/crConnection.js:211:39
Node.js v20.5.1
This thread is trying to answer question "Why does running headless: false in playwright 1.38 give a 'page closed' error and how can it be fixed?"
// playwright-extra is a drop-in replacement for playwright, // it augments the installed playwright with plugin functionality const { chromium } = require('playwright-extra')
// Load the stealth plugin and use defaults (all tricks to hide playwright usage) // Note: playwright-extra is compatible with most puppeteer-extra plugins const stealth = require('puppeteer-extra-plugin-stealth')()
// Add the plugin to playwright (any number of plugins can be added) chromium.use(stealth)
// That's it, the rest is playwright usage as normal 😊 chromium.launch({ headless: true }).then(async browser => { const page = await browser.newPage()
console.log('Testing the stealth plugin..') await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle' }) await page.screenshot({ path: 'stealth.png', fullPage: true })
console.log('All done, check the screenshot. ✨') await browser.close() })
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].