| name | playwright-doc-scraper-reliability |
| description | Improve Playwright scraping robustness for docs extraction with resilient waits, fallback strategy, and traceable debugging. Use when scraper behavior is flaky, slow, or failing on site structure changes. |
Playwright Doc Scraper Reliability
Use this skill for changes in src/lib/helpScraper.ts and src/lib/helpSearch.ts that rely on Playwright page behavior.
When to use
- Timeout or flaky extraction issues.
- Selector drift from Help or Developer docs pages.
- Need to add fallback extraction without masking root causes.
- Need better debug instrumentation for transient failures.
Reliability rules
- Wait for meaningful readiness signals, not arbitrary sleeps.
- Prefer resilient selection strategies and avoid brittle chains.
- Keep fallback logic explicit and bounded.
- Log recoverable failures in debug mode.
- Preserve deterministic final error conditions.
Practical strategy
- Start with
domcontentloaded, then conditionally wait for the specific content path.
- Keep cookie/consent handling reusable and isolated.
- Layer extraction attempts in descending quality.
- Validate extracted content length/shape before accepting output.
- If all extraction paths fail, return explicit failures with context.
Repo guidance
- Share browser interaction helpers in small modules (example:
src/lib/browserConsent.ts).
- Keep markdown conversion pure and separately testable (example:
src/lib/helpScraperMarkdown.ts).
- Preserve regression stability with
npm run regression:check before finalizing scraper changes.
Debug workflow
- Reproduce with command
--debug and --no-cache.
- Capture what failed and which fallback path was used.
- Add/adjust targeted tests for the specific break mode.
- Run unit tests and strict regression suite.
Checklist
References