Skip to content

[Bug]: getByRole does not highlight the corresponding element in the browser if the selector spans multiple lines #38366

@projeffboy

Description

@projeffboy

Version

^1.40.0

Steps to reproduce

  1. Clone https://github.com/projeffboy/playwright-vscode-extension-getbyrole-bug (will delete this once this issue is closed)
  2. Run npm install
  3. Make sure you have the playwright vscode extension installed.
  4. Run the test using the vscode playwright extension while enabling "Show Browser"
  5. Follow what I did in the video shown below. The issue is that if the getByRole selector spans multiple lines, the highlight on browser feature doesn't work anymore.
    Note: This is likely the issue [Question] Does getByRole work like locator in vscode? #18246 that this person ran into.
playwright-vscoide-extension-getbyrole-bug.mov

Expected behavior

Clicking on getByRole causes the corresponding element to be highlighted in the browser

Actual behavior

The corresponding element is only highlighted if the getByRole does not span multiple lines

Additional context

No response

Environment

System:
    OS: macOS 26.1
    CPU: (8) arm64 Apple M2
    Memory: 89.95 MB / 16.00 GB
  Binaries:
    Node: 22.7.0 - /Users/projeffboy/.nvm/versions/node/v22.7.0/bin/node
    npm: 10.8.2 - /Users/projeffboy/.nvm/versions/node/v22.7.0/bin/npm
    pnpm: 10.13.1 - /Users/projeffboy/Library/pnpm/pnpm
  IDEs:
    VSCode: 1.106.3 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.40.0 => 1.57.0

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