Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible with Playwright to filter out only the visible elements in combination with a getBy locator?

Tags:

playwright

I'm trying to make a locator based on a getBy locator that returns only the visible elements. Is this possible?

Chaining a getBy locator with visible=true doesn't work: getByRole('textbox') >> visible=true And the documentation doens't show a visible filter option, for the getBy locators. I'm I missing something?

like image 955
L B Avatar asked Nov 01 '25 11:11

L B


1 Answers

As suggested here, you can filter out not visible fields using this:

page.getByText('Waiting for response...', { exact: true }).locator('visible=true');
like image 133
Don Diego Avatar answered Nov 03 '25 21:11

Don Diego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!