Documentation
REFERENCE
Selector Object
A selector that identifies page elements to perform an action with them (click, drag, etc.) or check their state in an assertion.
Use the Selector constructor to create a selector.
import { Selector } from 'testcafe';
const article = Selector('#article-content');
The following methods filter elements from the selector:
Method | Description |
---|---|
nth | Finds an element by its index. |
withText | Finds an element whose content includes the specified text. |
withExactText | Finds an element with the specified text. |
withAttribute | Finds an element with the specified attribute or attribute value. |
filterVisible | Selects visible elements. |
filterHidden | Selects hidden elements. |
filter | Finds elements that match the specified CSS selector or predicate. |
Methods that search for DOM elements relative to the selected element:
Method | Description |
---|---|
find | Finds a descendant node that matches the specified CSS selector or predicate. |
parent | Selects parent elements. |
child | Selects child elements. |
sibling | Selects sibling elements. |
nextSibling | Selects succeeding sibling elements. |
prevSibling | Selects preceding sibling elements. |
shadowRoot | Selects the shadow root hosted by the element. |
For more information, see Select Page Elements.