Webwright
Webwright copied to clipboard
fix: force UTF-8 stdout in Playwright patterns to prevent UnicodeEncodeError on Windows
Summary
Forces UTF-8 stdout encoding in the canonical Playwright code skeletons to prevent UnicodeEncodeError on Windows.
Problem
On Windows, Python defaults sys.stdout.encoding to cp1252. When aria_snapshot() returns characters outside that codepage (CJK, math symbols, typography glyphs like ▽), the print() call crashes:
UnicodeEncodeError: 'charmap' codec can't encode character '▽'
A Windows user copy-pasting the recommended skeleton from Webwright's own reference doc will hit this on the first non-trivial page.
Fix
Added sys.stdout.reconfigure(encoding="utf-8") to both code skeletons:
- Browser launch skeleton (line ~18)
- Final-script instrumentation example (line ~131)
This is a no-op on POSIX where stdout is already UTF-8, so it's fully portable.
Fixes #7