#!/usr/bin/env node const { chromium } = require('playwright'); async function testPlaywright() { console.log('๐Ÿงช Testing Playwright installation...'); try { // Launch browser console.log(' ๐Ÿš€ Launching Chromium...'); const browser = await chromium.launch({ headless: true }); console.log(' โœ… Browser launched successfully'); // Create page const page = await browser.newPage(); console.log(' โœ… Page created'); // Navigate to a simple page console.log(' ๐Ÿ”— Navigating to example.com...'); await page.goto('https://example.com', { waitUntil: 'domcontentloaded' }); // Test selector const title = await page.title(); console.log(` โœ… Page title: "${title}"`); // Test waitForFunction await page.waitForFunction(() => document.title === 'Example Domain', { timeout: 5000 }); console.log(' โœ… waitForFunction works'); // Test locator const h1 = await page.locator('h1').textContent(); console.log(` โœ… Locator found: "${h1}"`); // Close browser await browser.close(); console.log(' โœ… Browser closed'); console.log('\n๐ŸŽ‰ All tests passed! Playwright is ready to use.'); return true; } catch (error) { console.error(`\nโŒ Test failed: ${error.message}`); return false; } } testPlaywright() .then(success => { process.exit(success ? 0 : 1); }) .catch(error => { console.error('Unexpected error:', error); process.exit(1); });