Skip to content

[Bug]: 1.63 regression - page.frame(...).locator(...).highlight highlights elements in the wrong frame #42850

Closed

Description

@DetachHead

Version

1.63.0

Steps to reproduce

import { test } from '@playwright/test'

test('frame highlight', async ({ page }) => {
    await page.setContent(
        '<iframe name="frame" srcdoc="<button>foo</button>"></iframe><button>bar</button>',
    )
    const locator = page.frame('frame')!.locator('button')
    await locator.highlight() // incorrectly highlights the "bar" button outside the frame
    await locator.click() // correctly clicks the "foo" button inside the frame
})

Expected behavior

the button inside the frame is highlighted

Actual behavior

the button outside the frame is highlighted

Image

Additional context

possibly related: #42849

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11500H @ 2.90GHz
    Memory: 9.94 GB / 31.20 GB
  Binaries:
    Node: 26.3.1 - C:\Users\user\AppData\Roaming\node\node.EXE
    npm: 11.16.0 - C:\Users\user\AppData\Roaming\node\npm.CMD
  IDEs:
    VSCode: 1.134.0 - C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  npmPackages:
    @playwright/test: 1.63.0 => 1.63.0 
    playwright-core: ^1.43.0 => 1.63.0

Activity

  1. ashrafiucse commented on Sep 22, 2026

    @ashrafiucse
    Contributor

    Confirmed on main, reproduced with the example from the report — click() lands on the correct button inside the frame, but the highlight overlay shows up on the button in the main document.

    This looks like a regression from #42277. FrameDispatcher.highlight now hands just the selector to the page-level HighlightController, and _resolve() re-resolves every entry starting from page.mainFrame(), so the frame the locator belongs to gets dropped along the way. css=button then matches the bar button in the main document.

    Working on a PR — the plan is to thread the originating frame through the highlight entry and resolve relative to it, which restores the old per-frame frame.addHighlight() behavior.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions