ページ上の要素を検索します。検索された要素は、特別なウェブ要素オブジェクト(便利なメソッドが追加されています)として返されます。
引数は、要素セレクタです。文字列またはオブジェクト('selector'と'locateStrategy'のプロパティを持つ)として指定します。
別の要素を起点として要素を検索できます。
検索条件に一致する要素が複数ある場合、最初の要素のみが返されます。
使用方法
browser.element.find(selector)
例
export default {
demoTest(browser: NightwatchAPI): void {
// Using element function (alias for find).
const button1 = browser.element('button.submit-form');
// Using the find method of the element namespace.
const button2 = browser.element.find('button.submit-form');
// Searching for the icon element inside the .submit-form button.
const icon = button2.find('i');
// Use an object to customise locating behaviour.
const main = browser.element({ selector: 'main', locateStrategy: 'css selector' });
},
async demoTestAsync(browser: NightwatchAPI): Promise<void> {
// button is the WebElement object.
const button = await browser.element('button.submit-form');
}
}
パラメータ
名前 |
型 |
説明 |
selector |
文字列 | オブジェクト |
|
戻り値