Settings

Theme

Playwright's getByRole is 1.5x slower than CSS selectors

serpapi.com

1 points by ilyazub 2 years ago · 1 comment

Reader

ilyazubOP 2 years ago

I recently wrote a blog post where I take a deep look into Playwright’s locators, specifically comparing the Page#getByRole locator with CSS selectors in terms of performance.

Playwright’s getByRole is 1.5x slower than CSS selectors because Page#getByRole uses querySelectorAll('*') and matches elements by the accessible name.

The post breaks down how `getByRole` works under the hood, how it stacks up against CSS selectors performance-wise, and what this means for your testing suites.

Would love to hear your thoughts!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection