Skip to main content

Function: byCssSelector()

byCssSelector(selector, relativeTo): CssLocator

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

Locate elements using a raw CSS selector string.

This is a low level API and should be used when the other helper locators cannot express the desired selector.

Parameters​

selector​

string

A CSS selector string.

relativeTo​

LocatorRelativePosition = 'Descendant'

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

Returns​

CssLocator

Example​

const activeItem = byCssSelector('.menu .item.active');