M2: Playwright essentials (v0.4.0) #5

Merged
akib merged 12 commits from akib/m2-essentials into main 2026-11-08 04:04:21 +00:00 AGit
Owner

M2 of the plan (docs/IMPLEMENTATION.md): the Playwright essentials that were missing. Version 0.4.0, 49 blocks (6 new).

What's in it

  • Locators (M2.1, M2.2):
    • Filters >> has-text=, has-not-text=, has=, has-not=, visible, plus A || B.
    • Role states [pressed], [expanded], [selected], [disabled].
    • The picker uses has-text when nothing simpler is unique. Role options are stricter: [checked=yes] is now an error.
  • Assert (M2.9): class, css, focused, editable, in-viewport, accessible-name, accessible-description.
  • Keys (M2.14): chords like Control+Shift+K and ControlOrMeta+A work in both input modes. Press Key gets mode: "text" (insertText).
  • Click (M2.3): button, modifiers, position (from the padding box, like Playwright) and clickCount. Old configs send the same request as before.
  • New block, Element Action (M2.4): focus, blur, clear, scroll into view, dispatch event (CustomEvent detail or a built-in event's init).
  • New block, Drag (M2.5):
    • Synthetic HTML5 drags and pointer drags (sliders, sortables).
    • Real input through CDP drag interception, as Playwright does it.
  • Upload File:
    • Drop zones, with target: "dropzone" (M2.6).
    • source: "data" (base64 or a data: URL). HTTP Request gets responseType: "base64" → body64 (M2.15).
  • New block, Wait for Download (M2.7): file name, size, MIME and URL. read fetches the file again as text, CSV or JSON.
  • New block, Screenshot (M2.8): visible area, full page or one element.
    • Chromium: full page and background tabs use CDP.
    • Firefox: everything through tabs.captureTab.
  • New block, Cookies & Storage (M2.10): get, set, delete and clear for cookies (including HttpOnly; new optional cookies permission) and for local/session storage.
  • Wait For (M2.13): request mode and a method filter. captureBody reads response bodies on Chromium, but only for responses that start after the step.
  • New block, Switch (M2.11): dynamic ports, one output per case plus default.
    • BlockDefinition.ports may now be a function of the config.
    • The editor moves connections when a case is renamed.
    • Scripts treat Switch like If.
  • Repeat (M2.12): mode: until | while, with max and failAtMax. done now carries iterations.
  • Playwright export: covers all of the above.

Fixes found while merging

  • e2e run() (Chromium and Firefox) could return an earlier run of the same workflow. It now waits for the new run.
  • Firefox, background tab: focus and blur events never fired. The page agent now fires them when the browser doesn't.
  • Firefox, drop zones: the page saw an empty dataTransfer.files. The agent now exposes a real FileList.

Test plan

  • npm run check: 680 unit/DOM tests; guide, learning and wiki checks pass
  • npm run build, npm run build:firefox
  • npm run e2e (system Chromium, headless): 18 specs, 207 checks. Includes m2-locators, m2-actions, m2-browser, m2-flow; the new blocks' exports pass under npx playwright test.
  • npm run e2e:firefox: 30 checks (Firefox 159). Includes downloads, screenshots, cookies, storage, requests, locator filters, Assert subjects, click options, Element Action, Drag, drop zone.
  • Not verified: real-input drag in a headed browser by hand; response-body capture for a response started by the step just before Wait For (documented limitation, M3 per-run CDP sessions would lift it).

After merge: npm run wiki:publish.

🤖 Generated with Claude Code

M2 of the plan (docs/IMPLEMENTATION.md): the Playwright essentials that were missing. Version 0.4.0, 49 blocks (6 new). ## What's in it - **Locators (M2.1, M2.2):** - Filters `>> has-text=`, `has-not-text=`, `has=`, `has-not=`, `visible`, plus `A || B`. - Role states `[pressed]`, `[expanded]`, `[selected]`, `[disabled]`. - The picker uses `has-text` when nothing simpler is unique. Role options are stricter: `[checked=yes]` is now an error. - **Assert (M2.9):** `class`, `css`, `focused`, `editable`, `in-viewport`, `accessible-name`, `accessible-description`. - **Keys (M2.14):** chords like `Control+Shift+K` and `ControlOrMeta+A` work in both input modes. Press Key gets `mode: "text"` (insertText). - **Click (M2.3):** `button`, `modifiers`, `position` (from the padding box, like Playwright) and `clickCount`. Old configs send the same request as before. - **New block, Element Action (M2.4):** focus, blur, clear, scroll into view, dispatch event (CustomEvent `detail` or a built-in event's init). - **New block, Drag (M2.5):** - Synthetic HTML5 drags and pointer drags (sliders, sortables). - Real input through CDP drag interception, as Playwright does it. - **Upload File:** - Drop zones, with `target: "dropzone"` (M2.6). - `source: "data"` (base64 or a data: URL). HTTP Request gets `responseType: "base64"` → `body64` (M2.15). - **New block, Wait for Download (M2.7):** file name, size, MIME and URL. `read` fetches the file again as text, CSV or JSON. - **New block, Screenshot (M2.8):** visible area, full page or one element. - Chromium: full page and background tabs use CDP. - Firefox: everything through `tabs.captureTab`. - **New block, Cookies & Storage (M2.10):** get, set, delete and clear for cookies (including HttpOnly; new optional `cookies` permission) and for local/session storage. - **Wait For (M2.13):** `request` mode and a `method` filter. `captureBody` reads response bodies on Chromium, but only for responses that start after the step. - **New block, Switch (M2.11):** dynamic ports, one output per case plus `default`. - `BlockDefinition.ports` may now be a function of the config. - The editor moves connections when a case is renamed. - Scripts treat Switch like If. - **Repeat (M2.12):** `mode: until | while`, with `max` and `failAtMax`. `done` now carries `iterations`. - **Playwright export:** covers all of the above. ## Fixes found while merging - e2e `run()` (Chromium and Firefox) could return an earlier run of the same workflow. It now waits for the new run. - Firefox, background tab: focus and blur events never fired. The page agent now fires them when the browser doesn't. - Firefox, drop zones: the page saw an empty `dataTransfer.files`. The agent now exposes a real FileList. ## Test plan - [x] `npm run check`: 680 unit/DOM tests; guide, learning and wiki checks pass - [x] `npm run build`, `npm run build:firefox` - [x] `npm run e2e` (system Chromium, headless): 18 specs, 207 checks. Includes `m2-locators`, `m2-actions`, `m2-browser`, `m2-flow`; the new blocks' exports pass under `npx playwright test`. - [x] `npm run e2e:firefox`: 30 checks (Firefox 159). Includes downloads, screenshots, cookies, storage, requests, locator filters, Assert subjects, click options, Element Action, Drag, drop zone. - [x] Not verified: real-input drag in a headed browser by hand; response-body capture for a response started by the step just before Wait For (documented limitation, M3 per-run CDP sessions would lift it). After merge: `npm run wiki:publish`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
akib added 12 commits 2026-11-06 08:45:15 +00:00
Co-Authored-By: Claude Opus 5.5 <[email protected]>
BlockDefinition.ports may be a function of the config; nodePorts/declaredPorts
read it everywhere (engine, check, validate, script, layout, exporter, editor,
schemas). Switch routes to the first matching case or default; the editor moves
connections on a case rename and drops them on removal (followPortChanges).
Repeat gets mode times/until/while with max and failAtMax; ctx.emit resolves
with the data at the end of the branch. Playwright export, guide example
api-status-router, docs, unit and e2e (m2-flow) tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Click: button (left/middle/right), modifiers, position (padding box, as
  Playwright), clickCount; `action` stays the quick choice. Old configs send
  the same request. Real input passes them to Input.dispatchMouseEvent.
- Element Action block (element-action): focus, blur, clear,
  scroll-into-view, dispatch-event (eventType + JSON detail). New page ops
  focus, blur, clear, dispatch.
- Drag block (drag) + op `drag`: synthetic HTML5 drag with a shared
  DataTransfer, or pointer/mouse moves for pointer-event drags; real input
  via CDP drag interception (mouseDrag in cdp.ts).
- Upload File: target input | dropzone, source data (base64 or data: URL).
  HTTP Request responseType base64 -> body64 + mime.
- Playwright export for all of it; fixtures clicks.html, dnd.html, drop
  zone in upload.html; e2e spec m2-actions; jsdom, unit and exporter tests;
  guide, block reference and wiki updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	docs/IMPLEMENTATION.md
#	docs/PLAN.md
#	docs/guide/blocks.md
#	docs/wiki/Block-Internals.md
#	docs/wiki/Browser-Host.md
#	docs/wiki/Page-Protocol.md
#	docs/wiki/Workflows-as-Scripts.md
#	src/browser/cdp.ts
#	src/browser/pageDriver.ts
#	src/core/playwright.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- wait-for-download: Host.downloads.waitFor (downloads.search look-back, claimed ids in
  storage.session bf:downloads-claimed) and readText (re-fetch http/data, blob: in the page);
  read as text / CSV / JSON, optional dataset.
- screenshot: Host.screenshots.take; visible / full page / element. Chromium: captureVisibleTab
  or CDP Page.captureScreenshot (captureBeyondViewport + clip); Firefox: tabs.captureTab + rect.
  New agent op measure. The engine shows an output screenshotId on the step.
- cookies-storage: Host.cookies (optional cookies permission) and the storage op's new
  set/delete/clear actions.
- Wait For: mode request (webRequest request log with bodies), method filter, captureBody via
  CDP Network.getResponseBody (Chromium).
- BlockDefinition.permissions may be a function of the config; new error code download.failed.
- Playwright export for all of them; unit, jsdom, e2e (m2-browser) and Firefox e2e checks; docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	docs/IMPLEMENTATION.md
#	docs/PLAN.md
#	docs/guide/README.md
#	docs/guide/blocks.md
#	docs/wiki/Block-Internals.md
#	docs/wiki/Testing.md
#	src/core/blocks/index.ts
#	tests/fixtures/site/m2.html
Firefox moves focus in a tab that is not showing without firing focus/blur, and hides a synthetic
drop's files from the page. The page agent now fires the focus events itself when the browser did
not, and gives the page's view of the DataTransfer a real FileList. The Firefox runner gains checks
for locator filters, role states, Assert subjects, click options, Element Action, Drag and drop
zones, and waits for the new run like the Chromium harness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
akib merged commit e03b361e97 into main 2026-11-08 04:04:21 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
akib/blockflow!5
No description provided.