aboutsummaryrefslogtreecommitdiff
path: root/playwright-js/run.js
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-22 15:48:48 -0500
committerCraig Jennings <c@cjennings.net>2026-05-22 15:48:48 -0500
commit8c291b81cd7fb10479a55fb47e9a9cebcfc1b9b8 (patch)
tree9f4d2fc7d3dff7f5404576759fee9d4a44f74b73 /playwright-js/run.js
parente6f8db82fb3e97ebf11866de2166ff4505871c21 (diff)
downloadrulesets-8c291b81cd7fb10479a55fb47e9a9cebcfc1b9b8.tar.gz
rulesets-8c291b81cd7fb10479a55fb47e9a9cebcfc1b9b8.zip
refactor(skills): locator-first playwright guidance, drop emoji markers
Two cleanups to the playwright skills, landed together since they overlap the same files. The skills taught networkidle as the readiness check and leaned on raw page.click/fill/waitForSelector. Playwright discourages networkidle for readiness, so the guidance in both SKILL.md files now waits for a visible app landmark via a web assertion or locator, the login and form examples use getByLabel/getByRole plus expect, the API reference leads with that pattern, and lib/helpers.js defaults waitForPageReady to load (preferring a caller-supplied landmark) and races the success indicator in authenticate instead of waiting on networkidle. The second cleanup strips emoji console markers across run.js, helpers.js, both SKILL.md files, and the py examples, replacing each with a plain ASCII tag like [ok], [error], or [scan]. node --check and py_compile pass, and an emoji grep comes back clean.
Diffstat (limited to 'playwright-js/run.js')
-rwxr-xr-xplaywright-js/run.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/playwright-js/run.js b/playwright-js/run.js
index 10f2616..ade36cb 100755
--- a/playwright-js/run.js
+++ b/playwright-js/run.js
@@ -33,14 +33,14 @@ function checkPlaywrightInstalled() {
* Install Playwright if missing
*/
function installPlaywright() {
- console.log('šŸ“¦ Playwright not found. Installing...');
+ console.log('[setup] Playwright not found. Installing...');
try {
execSync('npm install', { stdio: 'inherit', cwd: __dirname });
execSync('npx playwright install chromium', { stdio: 'inherit', cwd: __dirname });
- console.log('āœ… Playwright installed successfully');
+ console.log('[setup] Playwright installed successfully');
return true;
} catch (e) {
- console.error('āŒ Failed to install Playwright:', e.message);
+ console.error('[error] Failed to install Playwright:', e.message);
console.error('Please run manually: cd', __dirname, '&& npm run setup');
return false;
}
@@ -55,24 +55,24 @@ function getCodeToExecute() {
// Case 1: File path provided
if (args.length > 0 && fs.existsSync(args[0])) {
const filePath = path.resolve(args[0]);
- console.log(`šŸ“„ Executing file: ${filePath}`);
+ console.log(`[file] Executing file: ${filePath}`);
return fs.readFileSync(filePath, 'utf8');
}
// Case 2: Inline code provided as argument
if (args.length > 0) {
- console.log('⚔ Executing inline code');
+ console.log('[inline] Executing inline code');
return args.join(' ');
}
// Case 3: Code from stdin
if (!process.stdin.isTTY) {
- console.log('šŸ“„ Reading from stdin');
+ console.log('[stdin] Reading from stdin');
return fs.readFileSync(0, 'utf8');
}
// No input
- console.error('āŒ No code to execute');
+ console.error('[error] No code to execute');
console.error('Usage:');
console.error(' node run.js script.js # Execute file');
console.error(' node run.js "code here" # Execute inline');
@@ -146,7 +146,7 @@ function getContextOptionsWithHeaders(options = {}) {
try {
${code}
} catch (error) {
- console.error('āŒ Automation error:', error.message);
+ console.error('[error] Automation error:', error.message);
if (error.stack) {
console.error(error.stack);
}
@@ -163,7 +163,7 @@ function getContextOptionsWithHeaders(options = {}) {
try {
${code}
} catch (error) {
- console.error('āŒ Automation error:', error.message);
+ console.error('[error] Automation error:', error.message);
if (error.stack) {
console.error(error.stack);
}
@@ -180,7 +180,7 @@ function getContextOptionsWithHeaders(options = {}) {
* Main execution
*/
async function main() {
- console.log('šŸŽ­ Playwright Skill - Universal Executor\n');
+ console.log('Playwright Skill - Universal Executor\n');
// Clean up old temp files from previous runs
cleanupOldTempFiles();
@@ -205,16 +205,16 @@ async function main() {
fs.writeFileSync(tempFile, code, 'utf8');
// Execute the code
- console.log('šŸš€ Starting automation...\n');
+ console.log('[run] Starting automation...\n');
require(tempFile);
// Note: Temp file will be cleaned up on next run
// This allows long-running async operations to complete safely
} catch (error) {
- console.error('āŒ Execution failed:', error.message);
+ console.error('[error] Execution failed:', error.message);
if (error.stack) {
- console.error('\nšŸ“‹ Stack trace:');
+ console.error('\n[trace] Stack trace:');
console.error(error.stack);
}
process.exit(1);
@@ -223,6 +223,6 @@ async function main() {
// Run main function
main().catch(error => {
- console.error('āŒ Fatal error:', error.message);
+ console.error('[error] Fatal error:', error.message);
process.exit(1);
});