.findByAltText() 建議編輯
自版本:3.0.0在頁面上搜尋具有指定文字的 alt
屬性的元素。
可以使用另一個元素作為起點來搜尋元素。
預設情況下,提供的文字會被視為子字串,因此 'foo'
也會符合 'foobar'
。
如果需要精確比較,請提供 { exact: true }
作為第二個參數。
用法
browser.element.findByAltText(text, [options])
範例
export default {
demoTest(browser: NightwatchAPI): void {
// Search by the substring mathing.
const image = browser.element.findByAltText('group of people');
// Search for the exact occurrence.
const image = browser.element.findByAltText(
'A group of people sitting in front of a computer.',
{ exact: true }
);
}
}
參數
名稱 | 類型 | 描述 |
---|---|---|
text |
字串 | |
options 選填 |
[物件 物件] |
回傳值
類型 | 描述 |
---|---|
Array.<ScopedWebElement> |