Skip to content

[Bug]: Inspector will not highlight locators that are placed inside locators #31407

Open
@james-potter-CeraCare

Description

@james-potter-CeraCare

Version

1.44.1

Steps to reproduce

Using the code below the test passes the first assertion as expected and fails on the second assertion citing locator('html').locator(locator('body')) as the locator.

Normally the locator cited can be copied into the inspector to check the locator, however it does not recognise
locator('html').locator(locator('body'))

You need to manipulate this locator string to this:
locator('html').locator('body')

test('test', async ({ page }) => {
  await page.goto('https://www.google.com/');

  let html = page.locator("html")
  let body = page.locator("body")


  let bodyCombined = html.locator(body)

  //Passes
  await expect(bodyCombined).toContainText("About")

  //Fails citing "locator('html').locator(locator('body'))"
  await expect(bodyCombined).toContainText("About1111")
});

Expected behavior

I expect locator('html').locator(locator('body')) to highlight the element in the playwright inspector

OR

The locator cited in the error to show locator('html').locator('body')
(this is less perferrable)

Actual behavior

locator('html').locator(locator('body')) cited in the error returns nothing when using it in the playwright inspector

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13700H
    Memory: 12.54 GB / 31.68 GB
  Binaries:
    Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @playwright/test: ^1.44.1 => 1.44.1 
    playwright: ^1.44.1 => 1.44.1 
    playwright-qase-reporter: ^2.0.4 => 2.0.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions