Skip to main content

Selector Configuration

Every selector accepts configuration as a second argument:

type ExternalSelectorConfig = {
alias?: string;
parentAlias?: string;
attribute?: string;
eq?: number;
timeout?: number;
parent?: Selector;
ignoreCase?: boolean;
};

alias#

Assigns an alias to a selector. This alias can be used to reference that element as a parent of another selector.

parentAlias#

Allows referencing parent of a selector via its alias.

note

Please note, that child-parent relationship via alias works only within one class.

attribute#

Custom attribute to be used by @ByAttribute selector. Being ignored by all other selectors.

eq#

Index of a DOM element in an array of elements.

note

Works with both XPath and CSS selectors. However, please note that it is not going to work if your XPath selector returns string, number or boolean.

timeout#

Selector timeout. By default, the library inherits timeout configuration from Cypress.

parent#

Allows referencing parent of a selector via reference to another selector.

note
  1. This kind of child-parent relationship doesn't have 'one-class' limitation and works across all classes with selectors.
  2. It is possible to use the XPath selector as a parent for the CSS selector and vise versa.
  3. XPath selectors that specify parents, should use relative location path (e.g. ./div instead of //div). Otherwise, the parent attribute for XPath selector that uses absolute location path is going to be ignored.

ignoreCase#

Makes text selector case insensitive.

note

Works only with @ByExactText, @ByPartialText, @ByPartialLinkText and @ByExactLinkText selectors.