Skip to content

[Feature]: Visible option for locators #31840

@qk5

Description

@qk5

🚀 Feature Request

I have a locator:
page.getByText('Waiting for response...', { exact: true });

And playwright points to multiple locators on screen, one visible locator and other invisible ones.

I only want the visible one, and my workaround is to use the following locator:
page.locator('div:has-text("Waiting for response..."):visible');

Please note that: If I remove the part :visible, this locator will behave the same as my first example using getByText()

So, is it possible to add an additional option within getByText() and other getBy locator methods for visible locator?

Maybe something like:
page.getByText('Waiting for response...', { visible: true });

Example

No response

Motivation

I believe having the visible option will give us more flexibility when creating any getBy locators.

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