Search for an element on the page that contains a specified text.
Element can be searched by using another element as the starting point.
By default, provided text is treated as a substring, so for the 'foo' will match 'foobar' also.
If you need an exact comparison, provide the { exact: true } as the second parameter.

Usage

                    browser.element.findByText(text, [options])
                

Example

export default {
  demoTest(browser: NightwatchAPI): void {
    // Search by the substring matching.
    const inputs = browser.element.findByText('group of people');

    // Search for the exact occurrence.
    const images = browser.element.findByText(
      'The nostalgic office',
      { exact: true }
    );
  }
}

Parameters

Name Type description
text string
options
Optional
[object Object]

Returns

Type description
ScopedWebElement