.findByLabelText() 建議編輯
自從: 3.0.0搜尋符合指定文字的標籤,然後找到與該標籤相關聯的元素。
可以使用另一個元素作為起點來搜尋元素。
預設情況下,提供的文字會被視為子字串,因此 'foo'
也會符合 'foobar'
。
如果需要完全比對,請將 { exact: true }
作為第二個參數傳遞。
用法
browser.element.findByLabelText(text, [options])
範例
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 }
);
}
}
參數
名稱 | 類型 | 描述 |
---|---|---|
文字 |
字串 | |
選項 選用 |
[object Object] |
回傳
類型 | 描述 |
---|---|
ScopedWebElement |