Documentation
REFERENCE
Selector.withExactText Method
Selects elements whose text content strictly matches the specified text.
Selector().withExactText(text) → Selector
Argument | Type | Description |
---|---|---|
text |
String | The element's text content. The text argument is case-sensitive. |
To search for elements that contain a specific text, use the withText method.
Example #
// Selects elements of the 'container' class
// whose text exactly matches 'foo'.
// Does not match 'bar', 'foobar', 'Foo'.
Selector('.container').withExactText('foo');
Notes #
withExactText
selects the element that contains the specified text and its ancestors (if they do not contain any other text). For an example, see the following section: withText.
To target elements with HTML symbols or HTML entities (e.g.,
, newline chars), refer to the following section: Select Elements That Contain Special Characters.