算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
playwright【设计与创意】Operate Playwright for browser automation end to end: author and debug E2E test suites (robust locators, network interception and mocking, parallel workers, accessibility snapshot checks), wire them into CI, and drive headless browsing and scraping with an extract -> validate -> save loop. Use when writing, running, fixing, or scraping with Playwrigh…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill to drive a real browser with Playwright: author end-to-end tests, keep selectors and tests robust, intercept and mock network traffic, run suites across parallel workers and in CI, scrape and extract data in headless mode, and check accessibility with snapshot scans. This is a tool skill for one named tool. Test strategy and framework selection belong to qa-methodology; frontend component and architecture design belong to frontend-engineering. This skill owns operating the Playwright tool itself.
playwright.config.*, projects, baseURL, webServer, workers, retries, and reporters before running anything. Never assume the test command from the README.getByRole, getByLabel, getByText) over CSS/XPath that encode markup. Tests coupled to user-visible behavior survive refactors; tests coupled to structure break on them.page.route() — never by patching in-page code. Mock the dependency under test's edges, never the code under test itself; a test that mocks what it claims to verify proves nothing.workers and sharding to the machine and suite, and never let tests share mutable state through globals.scripts/pwrun is an agent-first smoke harness around a Playwright suite. doctor, inventory, and report work with no node or Playwright installed, so an agent can inspect a suite and triage a CI report anywhere.
scripts/pwrun doctor --json # node, @playwright/test, browsers, config availability
scripts/pwrun inventory --json # config, projects, spec files in the suite
scripts/pwrun report --report test-results.json --json # summarize a Playwright JSON report
scripts/pwrun smoke --url http://localhost:3000 --json # delegate a smoke run to npx playwright test
Exit codes: 0 ok, 1 analysis error, 2 usage error, 127 dependency (node/playwright) missing, 124 delegate timeout. --json on every command; --help works without any toolchain.
For smoke, --config is forwarded to Playwright. The target URL precedence is --url, inherited PW_SMOKE_URL, inherited BASE_URL, then http://localhost:3000; the chosen target is passed to the supplied scaffold as PW_SMOKE_URL. The JSON result separates requested_url from navigation_evidence. The bundled example spec records the URL reached after page.goto(); custom specs need a pwrun-navigation annotation to provide the same runtime evidence. requested_target_origin_observed shows whether any recorded navigation reached the requested origin.
test.describe blocks, test.beforeEach setup, and per-feature fixture files. Keep specs short, focused on one user journey, and readable as prose.expect(locator).toBeVisible(), .toHaveText(), .toHaveURL()) — they auto-retry until a timeout and are the backbone of stable E2E tests. Avoid manual page.waitForTimeout sleeps.webServer in the config (Playwright starts it, waits for readiness, and tears it down), or reuse an already-running instance via baseURL for smoke passes.references/01-e2e-authoring.md.getByTestId for ids that exist only for tests).getByRole('row').filter({ hasText: 'Acme' })) instead of building one long brittle selector. Re-query rather than storing stale element handles.first(). A selector that can match the wrong thing will eventually.references/02-selectors.md.page.route() and fulfill, abort, or continue them. Use this to mock third-party APIs, inject fixtures, emulate offline or slow networks, and block analytics/trackers that pollute tests.page.goto navigation the test depends on.page.on('request')/page.on('response') to assert on what the app actually sent. Patterns and gotchas: references/03-network-interception-and-mocking.md.workers sets how many parallel processes run specs; fullyParallel lets every spec file run across workers. Scale to CPU count and browser memory, not to "as many as possible".--shard=1/4) for large suites. Every test runs in its own browser context, so isolation is default — keep it that way: no shared globals, no shared storage state, no test-order coupling.references/04-parallel-workers-and-sharding.md.npx playwright@1.62.1 install --with-deps), pin the Playwright version, and cache ~/.cache/ms-playwright.webServer, retries (retry flaky tests on CI only), and trace: 'on-first-retry' so failures are debuggable. Report with html/json/github and upload artifacts on failure.scripts/pwrun report --json — it summarizes stats, failing specs, and error messages without opening a browser. Full CI recipes: references/05-ci-integration.md.chromium.launch({ headless: true }), newContext, page.goto) to load JavaScript-rendered pages, then extract with locators and innerText/attribute access into structured records — extract, validate, save.references/06-scraping-and-headless.md.@axe-core/playwright to catch WCAG violations (contrast, landmarks, ARIA misuse) in CI or on demand.expect(page).toMatchAriaSnapshot()) as stable, accessibility-aware assertions: they compare the accessibility tree, so they catch structure and label regressions and read like spec assertions. Update deliberately, never --update-snapshots reflexively.references/07-accessibility-and-debugging.md.--headed), slow the action with --slow-mo, or drop into the inspector with --debug / PWDEBUG=1 and the page.pause() breakpoint.npx playwright@1.62.1 codegen <url>, then harden the generated selectors into user-facing locators.--trace on), which records network, DOM snapshots, and console for the failed action. Use scripts/pwrun report --report <json> --json first to see the failure summary.references/07-accessibility-and-debugging.md.| Load when | Reference |
|---|---|
| Writing or structuring specs, fixtures, page objects | references/01-e2e-authoring.md |
| A selector is flaky or matches the wrong element | references/02-selectors.md |
| Mocking or intercepting API/network traffic | references/03-network-interception-and-mocking.md |
| Speeding up or sharding a large suite | references/04-parallel-workers-and-sharding.md |
| Wiring Playwright into CI or triaging CI failures | references/05-ci-integration.md |
| Extracting data or browsing in headless mode | references/06-scraping-and-headless.md |
| Accessibility scans, aria snapshots, or debugging a failing test | references/07-accessibility-and-debugging.md |
| Sources, version observations, and refresh procedure | references/00-source-index.md |
scripts/pwrun: smoke harness — doctor, inventory, report, smoke, all with --json.tests/test_pwrun.py + tests/fixtures/sample-report.json: deterministic tests for the harness (no node/browser required).tests/test_pwrun_scaffold.py: bounded local-server/browser integration check; runs when @playwright/test and Chromium are installed.templates/playwright.config.ts, templates/example.spec.ts, templates/accessibility.spec.ts: copy-in test-suite scaffold.references/: eight dated, source-indexed references covering the operational topics above.| Claim | Minimum evidence |
|---|---|
| Toolchain is present | scripts/pwrun doctor --json reports node, @playwright/test, and browsers available |
| Suite is understood | scripts/pwrun inventory --json lists config and spec files |
| A test passes | npx playwright@1.62.1 test exit 0 on the targeted spec (or smoke delegation) |
| A CI failure is explained | scripts/pwrun report --report test-results.json --json names the failing specs and errors |
| Accessibility is covered | An axe scan runs with zero violations of the declared severity, and aria snapshots match |
| No regressions in the covered flows | The suite ran under the configured workers/sharding with expected/flaky/unexpected counts recorded |
playwright/.auth/* storage state, .env, or browser credentials.--update-snapshots blindly to "fix" an aria snapshot diff — inspect what changed first.pwrun report instead.qa-methodology's performance-testing reference.The catalog's automated topic sweep greps this file for coverage keywords. Two
alias pairs are written literally below so the sweep matches both spellings:
e2e|end-to-end covers browser-level tests (E2E, end-to-end, and e2e are the
same workflow), and debug|head covers the headed-debugging workflows in this
skill. All other topics (selector robustness, network interception, parallel
workers, CI integration, scraping, accessibility snapshots, mocking) appear by
name in the sections above.