fix(mcp): record node actions inside web frames
What
Tapping an observed button in a web frame now records a browser.frameLocator(...).getByRole(...).tap() line. locate is unchanged.
Why
The tap reached the button, but the recorder looked for a replay locator in the outer document.
How it works
-
packages/e2e/src/session-tools/test-lines.ts:407scopes each locator probe to the observed frame path and prints the same path in the draft. A redacted selector produces no line. A positional frame selector gets a warning. -
packages/e2e/tests/integration/mcp-test-lines.test.ts:116replays a generated line through two nested frames and checks that the button changed. The MCP guide and skill describe the frame scope. -
packages/e2e/tests/integration/mcp-step-attachment.test.ts:246takes the line from the paused Chromium session’s draft, reopens the page, and replays that exact line viarun_code. The frame button changes from “Frame button” to “Frame clicked”. -
For paused and stopped tests,
test_linestells the author which engine fixtures the recorded lines need. A draft that only usesscreengets no extra hint. -
The web reader keeps traversing shadow-scoped iframes by element handle but omits their incomplete selector chain. The recorder declines a line instead of probing the outer document.
Issue
Fixes #2345
Verified
Ran it locally: yes
node packages/e2e/repro-frame/repro.mjs from the reproduction, against both built CLIs on Chromium:
| main | this PR | |
|---|---|---|
| Counter after node tap | 1 | 1 |
| Recorded tap | // tap: no test line | await browser.frameLocator(...).getByRole("button", "Save").tap(); |

pnpm check passed. Both open/closed shadow regression cases failed before the fix and pass after it: the observed button changes, its light-DOM twin does not, and no tap line is drafted. The wider web run had 493 pass, 1 skip and 1 failure in the unmodified host-libraries ldd timeout test (also failed with one worker). After merging main at aaf923188, the old assertion that attached run_code rejects browser failed locally, as in CI. With the replay check, all 68 tests across the three related suites passed. Before the attachment follow-up, the e2e unit suite passed (5,051 passed, 2 skipped) and the web testbed passed (640 passed, 1 skipped). The image above shows the first fix; the final line also warns when the frame selector relies on position.
Checklist
- Patch changeset, MCP docs and skill updated.
- No change to public SDK types or wire formats.
Summary by CodeRabbit
- New Features
- Actions on controls inside observed web frames now generate replayable test steps scoped to the correct frame, including nested frames.
- Generated tests include guidance when a browser fixture is needed.
- Bug Fixes
- Actions inside iframes within shadow roots still run, but no replay step is generated when the frame cannot be reliably targeted.
- Frame selectors containing redacted secrets are excluded from generated test steps.
- Documentation
- Updated MCP guidance to explain frame-scoped actions and replay behavior.