ElementFilterOptions
Provides advanced filtering criteria for element selection, often used in conjunction with ElementOptions. These filters are applied AFTER an initial set of elements is found by the main selector in ElementOptions.
Definition
Fields
has
: ElementOptions
Narrows down the selection to elements that have a descendant matching these ElementOptions.
Example: To find a list item that contains a link with text “Details”:
element(selector: "li", filter: { has: { role: "link", text: "Details" } })
hasNot
: ElementOptions
Narrows down the selection to elements that DO NOT have a descendant matching these ElementOptions.
Example: To find a product item that does not contain a “Sold Out” badge:
element(selector: ".product", filter: { hasNot: { text: "Sold Out" } })
hasNotText
: String
Filters elements that DO NOT contain the specified text anywhere in their DOM subtree.
The match is case-insensitive. Can be a string or a regular expression pattern.
Example: hasNotText: "spam"
or hasNotText: "/advertisement/i"
hasText
: String
Filters elements that contain the specified text anywhere in their DOM subtree.
The match is case-insensitive. Can be a string or a regular expression pattern.
Example: hasText: "important"
or hasText: "/urgent/i"
visible
: Boolean
Filters elements based on their visibility. If true, only currently visible elements are matched. If false, only hidden elements are matched. If not specified, visibility is not checked. Visibility is determined by factors like ‘display: none’, ‘visibility: hidden’, opacity, and element size.