Skip to main content

Function: byLinkedElement()

byLinkedElement(relative?): object

Defined in: packages/core/src/locators/byLinkedElement.ts:19

Experimental locator that matches an element by relating it to another element on the page. It is useful when two elements share related attributes.

Parameters​

relative?​

LocatorRelativePosition = 'Descendant'

Relative position for the resulting locator. Defaults to 'Descendant'.

Returns​

object

onLinkedElement​

onLinkedElement: (locator) => object

Parameters​

locator​

PartLocator

Returns​

object

extractAttribute​

extractAttribute: (attributeName) => object

Parameters​
attributeName​

string

Returns​

object

toMatchMyAttribute​

toMatchMyAttribute: (myAttributeName) => LinkedCssLocator

Parameters​
myAttributeName​

string

Returns​

LinkedCssLocator

Example​

const label = byLinkedElement().onLinkedElement(byDataTestId('input'))
.extractAttribute('for')
.toMatchMyAttribute('id');