Skip to content

feat(api): Page.hideHighlight, rename ref → target#40219

Merged
pavelfeldman merged 1 commit intomicrosoft:mainfrom
pavelfeldman:highlight-hide
Apr 15, 2026
Merged

feat(api): Page.hideHighlight, rename ref → target#40219
pavelfeldman merged 1 commit intomicrosoft:mainfrom
pavelfeldman:highlight-hide

Conversation

@pavelfeldman
Copy link
Copy Markdown
Member

Summary

  • new Page.hideHighlight() API that clears all locator highlights on the page
  • MCP browser_hide_highlight and CLI highlight --hide (no target) clear all highlights when called without a specific element
  • renames the snapshot-derived element identifier across MCP/CLI from ref to target (elementSchema, browser_drag's startTarget/endTarget, Tab.targetLocator/targetLocators, CLI args, tests). The aria-ref= selector engine and Locator.ariaRef() are unrelated and stay as-is.

- Adds `Page.hideHighlight()` public API that clears all locator highlight
  overlays added on the page. Implemented as a new internal Page channel
  command routed to the existing server-side `Page.hideHighlight()`.

- MCP `browser_hide_highlight` now accepts an optional element: with a
  target it removes that highlight; without one it calls `page.hideHighlight()`
  to clear them all. CLI `highlight --hide` (no target) does the same.

- Renames the snapshot-derived element identifier across the MCP/CLI surface
  from `ref` to `target` for consistency:
    - `elementSchema`/`optionalElementSchema`: `ref` → `target`.
    - `browser_drag` schema: `startRef`/`endRef` → `startTarget`/`endTarget`.
    - `Tab.refLocator`/`refLocators` → `targetLocator`/`targetLocators`,
      parameter `ref` → `target`.
    - All MCP tool handlers updated.
    - CLI `commands.ts` argument names back to `target`.
    - Tests updated to send `arguments: { target: 'eN' }`.

  The internal `aria-ref=` selector engine and the `Locator.ariaRef()` API
  are unrelated and stay as-is.
export const optionalElementSchema = z.object({
ref: z.string().optional().describe('Element reference from the previous page snapshot to capture a partial snapshot instead of the whole page'),
selector: z.string().optional().describe('Element selector of the root element to capture a partial snapshot instead of the whole page'),
element: z.string().optional().describe('Human-readable element description used to obtain permission to interact with the element'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this description mean? If the description is different depending on use case, make it a function that accepts the description as a param

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not changed, it is taken from elementDescription.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

2 failed
❌ [webkit-library] › library/locator-highlight.spec.ts:21 › highlight should accept a CSS string style @webkit-ubuntu-22.04-node20
❌ [webkit-library] › library/locator-highlight.spec.ts:40 › highlight should accept an object style (JS only) @webkit-ubuntu-22.04-node20

4 flaky ⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/video.spec.ts:476 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node22`

39172 passed, 847 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [chrome] › mcp/dashboard.spec.ts:26 › should show browser session chip @mcp-windows-latest

6043 passed, 976 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants