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] Matching locators by name is inaccurate due to escaped characters #20471

Closed
lukaskl opened this issue Jan 28, 2023 · 0 comments · Fixed by #20510
Closed

[BUG] Matching locators by name is inaccurate due to escaped characters #20471

lukaskl opened this issue Jan 28, 2023 · 0 comments · Fixed by #20510

Comments

@lukaskl
Copy link

lukaskl commented Jan 28, 2023

Context:

  • Playwright Version: 1.30.0
  • Operating System: Mac
  • Node.js version: v18.12.1
  • Visual Studio Code version: Version: 1.74.3 (Universal), Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
  • Playwright for VSCode extension version: 1.0.6
  • Browser: Chromium

Code Snippet

import { test } from "@playwright/test";

test("What's Installed heading", async ({ page }) => {
  await page.goto("https://playwright.dev/docs/intro");

  await page.getByRole("heading", { name: "What's Installed#", exact: true }).hover();     // passes, VS Code extension doesn't work
  await page.getByRole("heading", { name: "What\'s Installed#", exact: true }).hover();    // passes, VS Code extension works
  await page.getByRole("heading", { name: "What\\'s Installed#", exact: true }).hover();   // passes, VS Code extension doesn't work
  await page.getByRole("heading", { name: "What\\\'s Installed#", exact: true }).hover();  // passes, VS Code extension doesn't work
  await page.getByRole("heading", { name: "What\\\\'s Installed#", exact: true }).hover(); // fails,  VS Code extension doesn't work
});

Describe the bug

I believe that the same cause leads to at least 2 issues:

  • First, it is not accurate to allow to match locators by providing additional characters which do not exist on the browser (after all I'm passing a string not a regex). I believe that only the first getByRole here should pass and all the rest should fail:

    playwright-escaped-match-name.mp4
  • Second, VS Code extension picks up only the line with "What\'s Installed#" name (which I believe is ins't fully accurate) and doesn't show Locator tooltip when any other line (including "What's Installed#") is selected/hovered:

    playwright-vs-code-extension-locator.mp4

Notes:

I personally believe that this is a minor issue, I've noticed accidentally it only when I was recording a video for another issue. I don't have a real use case which would be blocked by this. Nonetheless, I still thought it is worthy to report this issue.

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 a pull request may close this issue.

1 participant