Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: addLocatorHandler displays incorrect error message #34070

Open
agg23 opened this issue Dec 18, 2024 · 0 comments · May be fixed by #34074
Open

[Bug]: addLocatorHandler displays incorrect error message #34070

agg23 opened this issue Dec 18, 2024 · 0 comments · May be fixed by #34074

Comments

@agg23
Copy link
Contributor

agg23 commented Dec 18, 2024

Version

1.49.1

Steps to reproduce

  1. Run the following test
test('repro', async ({ page, server }) => {
  await page.setContent(`<html><body><script>setTimeout(() => {document.body.innerHTML = '<div><ul><li>Foo</li></ul><ul><li>Bar</li></ul></div>'}, 100)</script></body></html>`);

  await page.addLocatorHandler(page.locator('ul'), async locator => Promise.resolve());

  await page.locator('ul > li').first().boundingBox();
});
  1. The following error will be thrown
    Error: locator.boundingBox: Error: strict mode violation: locator('ul') resolved to 2 elements:
        1) <ul>…</ul> aka getByRole('list').filter({ hasText: 'Foo' })
        2) <ul>…</ul> aka getByRole('list').filter({ hasText: 'Bar' })

    Call log:
      - waiting for locator('ul > li').first()


      379 |   await page.addLocatorHandler(page.locator('ul'), async locator => Promise.resolve());
      380 |
    > 381 |   await page.locator('ul > li').first().boundingBox();

Expected behavior

The error message should read something like:

Error: page.addLocatorHandler: Error: strict mode violation: locator('ul') resolved to 2 elements:

Actual behavior

The error message instead reads:

Error: locator.boundingBox: Error: strict mode violation: locator('ul') resolved to 2 elements:

Notice that it complains about locator.boundingBox even though that call did not fail.

Additional context

No response

Environment

System:
    OS: Windows 11 10.0.26100
    CPU: (6) x64 Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
    Memory: 2.76 GB / 15.81 GB
  Binaries:
    Node: 20.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.95.2 - C:\Users\agastineau\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants