.findByLabelText() Suggest edits
Since: 3.0.0Search for the label that matches the given text, then find the element associated with that label.
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.findByLabelText(text, [options])
Example
export default {
demoTest(browser: NightwatchAPI): void {
// Search by the substring matching.
const image = browser.element.findByLabelText('dreamers');
// Search for the exact occurrence.
const image = browser.element.findByLabelText(
'A group of people sitting in front of a computer.',
{ exact: true }
);
}
}
Parameters
Name | Type | description |
---|---|---|
text |
string | |
options Optional |
[object Object] |
Returns
Type | description |
---|---|
ScopedWebElement |