Created
May 12, 2026 17:04
-
-
Save scips/a549fdc31898c975714e7218aac54f8b to your computer and use it in GitHub Desktop.
A simple test with PlayRight headless browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { chromium } = require('playwright'); | |
| const fs = require('fs'); | |
| async function checkLogin() { | |
| const browser = await chromium.launch(); | |
| const context = await browser.newContext(); | |
| const page = await context.newPage(); | |
| try { | |
| await page.goto('https://yourwebsite.com/login'); | |
| // Fill in your credentials | |
| await page.fill('#username', 'your_test_user'); | |
| await page.fill('#password', 'your_password'); | |
| await page.click('#login-button'); | |
| // Wait for either a redirect or an error message | |
| await page.waitForLoadState('networkidle'); | |
| const currentUrl = page.url(); | |
| const errorMessage = await page.locator('.error-box').innerText().catch(() => null); | |
| let result = { | |
| timestamp: new Date().toISOString(), | |
| status: 'unknown', | |
| url: currentUrl, | |
| errorText: errorMessage | |
| }; | |
| if (currentUrl.includes('/dashboard')) { | |
| result.status = 'SUCCESS'; | |
| } else if (errorMessage) { | |
| result.status = 'ERROR_DISPLAYED'; | |
| } else { | |
| result.status = 'FAILED_UNKNOWN_PATTERN'; | |
| } | |
| // Append to a log file for pattern analysis | |
| fs.appendFileSync('login_logs.jsonl', JSON.stringify(result) + '\n'); | |
| console.log(`[${result.status}] checked at ${result.timestamp}`); | |
| } catch (err) { | |
| fs.appendFileSync('login_logs.jsonl', JSON.stringify({ timestamp: new Date().toISOString(), status: 'CRASH', error: err.message }) + '\n'); | |
| } finally { | |
| await browser.close(); | |
| } | |
| } | |
| checkLogin(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment