Uh oh!
There was an error while loading. Please reload this page.
feat(api): Locator.highlight({ style }) - #40215
Conversation
Adds an optional `style` to `Locator.highlight()`:
- All languages: `style?: string` — raw CSS declaration body, e.g.
`"outline: 2px dashed red; background: rgba(0,0,0,0.1)"`.
- JS only (documented in `overrides.d.ts`): the same `style` also accepts
a React-style object, e.g. `{ backgroundColor: 'yellow', outline: '2px dashed red' }`.
Converted to a CSS string on the client.
Also exposes the option through:
- MCP `browser_highlight` as optional `style: string`.
- CLI `highlight <el> --style=...`.
On the injected side, the per-selector tracking map now carries
`{ selector, cssStyle? }` so styles survive the RAF loop and
re-adding the same selector with a new style updates in place.| ### option: Locator.highlight.style | ||
| * since: v1.60 | ||
| - `style` <[string]> |
There was a problem hiding this comment.
in the code it can be an object
| async highlight() { | ||
| await this._frame._highlight(this._selector); | ||
| async highlight(options: { style?: string | Record<string, string | number> } = {}) { |
There was a problem hiding this comment.
without proper types, it's not very useful, I'd keep just string
15e92e1
into
microsoft:mainUh oh!
There was an error while loading. Please reload this page.
Test results for "MCP"1 failed 6029 passed, 964 skipped Merge workflow run. |
Test results for "tests 1"2 failed 4 flaky39165 passed, 847 skipped Merge workflow run. |
Ports the following upstream client-side PRs: - microsoft/playwright#39767 - feat: Add `location()` to `WebError` - microsoft/playwright#39950 - feat: page version of toMatchAriaSnapshot - microsoft/playwright#40083 - feat(locator): add `description` option to getByRole - microsoft/playwright#40092 - feat(expect): support pseudo-element in toHaveCSS - microsoft/playwright#40159 - feat(tracing): add tracing.startHar / tracing.stopHar - microsoft/playwright#40196 - chore: remove deprecated `handle` option from exposeBinding - microsoft/playwright#40215 - feat(api): Locator.highlight({ style }) - microsoft/playwright#40219 - feat(api): Page.hideHighlight, Locator.hideHighlight, highlight() returns AutoCloseable - microsoft/playwright#40283 - feat(locator): add drop API for files and clipboard-like data - microsoft/playwright#40315 - feat(browser): Browser.onContext / offContext - microsoft/playwright#40341 - feat(browsercontext): mirror Page lifecycle events on BrowserContext - microsoft/playwright#40377 - feat(route): expose WebSocket subprotocols on WebSocketRoute - microsoft/playwright#40606 - feat(api): unify WebError and ConsoleMessage location - microsoft/playwright#40651 - docs: alias drop-payload Object types Protocol shape change for FrameExpectResult.received (now `{ value, ariaSnapshot }` instead of a bare SerializedValue) — updated AssertionsBase to unwrap it. Generator updates: added new types to relevant import lists; share topLevelTypes between the assertion and non-assertion generate runs so PseudoElement gets emitted into options/.
Ports the following upstream client-side PRs: - microsoft/playwright#39767 - feat: Add `location()` to `WebError` - microsoft/playwright#39950 - feat: page version of toMatchAriaSnapshot - microsoft/playwright#40083 - feat(locator): add `description` option to getByRole - microsoft/playwright#40092 - feat(expect): support pseudo-element in toHaveCSS - microsoft/playwright#40159 - feat(tracing): add tracing.startHar / tracing.stopHar - microsoft/playwright#40196 - chore: remove deprecated `handle` option from exposeBinding - microsoft/playwright#40215 - feat(api): Locator.highlight({ style }) - microsoft/playwright#40219 - feat(api): Page.hideHighlight, Locator.hideHighlight, highlight() returns AutoCloseable - microsoft/playwright#40283 - feat(locator): add drop API for files and clipboard-like data - microsoft/playwright#40315 - feat(browser): Browser.onContext / offContext - microsoft/playwright#40341 - feat(browsercontext): mirror Page lifecycle events on BrowserContext - microsoft/playwright#40377 - feat(route): expose WebSocket subprotocols on WebSocketRoute - microsoft/playwright#40606 - feat(api): unify WebError and ConsoleMessage location - microsoft/playwright#40651 - docs: alias drop-payload Object types Protocol shape change for FrameExpectResult.received (now `{ value, ariaSnapshot }` instead of a bare SerializedValue) — updated AssertionsBase to unwrap it. Generator updates: added new types to relevant import lists; share topLevelTypes between the assertion and non-assertion generate runs so PseudoElement gets emitted into options/.
Summary
Locator.highlight({ style })— JS accepts a string or React-style object; other languages accept only a stringoverrides.d.ts; markdown documents the string formbrowser_highlightand CLIhighlight <el> --style{ selector, cssStyle? }so multiple highlights can have independent styles