.findByPlaceholderText() 建議編輯
自: 3.0.0在頁面上搜尋具有指定文字的 placeholder
屬性的元素。
可以使用另一個元素作為起點來搜尋元素。
預設情況下,提供的文字會被視為子字串,因此 'foo'
也會比對到 'foobar'
。
如果您需要精確的比對,請將 { exact: true }
作為第二個參數提供。
用法
browser.element.findByPlaceholderText(text, [options])
範例
export default {
demoTest(browser: NightwatchAPI): void {
// Search by the substring matching.
const inputs = browser.element.findByPlaceholderText('group of people');
// Search for the exact occurrence.
const images = browser.element.findByPlaceholderText(
'Search here',
{ exact: true }
);
const images = browser.element.findByPlaceholderText(
'Enter the number',
{ exact: true, suppressNotFoundError: true }
);
}
}
參數
名稱 | 類型 | 描述 |
---|---|---|
text |
字串 | |
options 選用 |
[物件 物件] |
回傳
類型 | 描述 |
---|---|
ScopedWebElement |