Selector describes an element in the page. It can be used to obtain
ElementHandle (see page.$() for example) or shortcut element operations to avoid intermediate handle (see page.click() for example).
Selector has the following format:
engine=body [>> engine=body]*. Here
engine is one of the supported selector engines (e.g.
body is a selector body in the format of the particular engine. When multiple
engine=body clauses are present (separated by
>>), next one is queried relative to the previous one's result.
Playwright also supports the following CSS extensions:
:text("string")- Matches elements that contain specific text node. Learn more about text selector.
:visible- Matches only visible elements. Learn more about visible selector.
:light(selector)- Matches in the light DOM only as opposite to piercing open shadow roots. Learn more about shadow piercing.
For convenience, selectors in the wrong format are heuristically converted to the right format:
- selector starting with
..is assumed to be
- selector starting and ending with a quote (either
') is assumed to be
- otherwise selector is assumed to be