Skip to content
public-library›Rules›Playwright›Scope locators by test id, then select controls by role and name

Scope locators by test id, then select controls by role and name

Locate elements through stable product contracts: scope to the surface you mean with its data-testid, then select the control inside it by accessible role and name. Never locate elements by CSS classes, DOM structure, or position.

In the full rule