Skip to main content

Function: byTagName()

byTagName(tagName, relative?): CssLocator

Defined in: packages/core/src/locators/byTagName.ts:24

Locate elements by their HTML tag name.

This locator is generally discouraged in favour of more stable attributes such as data-testid.

Parameters​

tagName​

string

The tag name to match.

relative?​

LocatorRelativePosition = 'Descendant'

Relative position of the locator. Defaults to 'Descendant'.

Returns​

CssLocator

Example​

const headings = byTagName('h1');