getLocation(位置を取得)
ページ上の要素の位置を特定します。座標 (0, 0) はページの左上の角を示します。
使用方法
$(selector).getLocation(prop)
パラメータ
名前 | 型 | 詳細 |
---|---|---|
prop | string | 簡単にアサーションを行うために、直接結果値を取得するための "x" または "y" を指定できます |
例
getLocation.js
it('should demonstrate the getLocation function', async () => {
await browser.url('http://github.com');
const logo = await $('.octicon-mark-github')
const location = await logo.getLocation();
console.log(location); // outputs: { x: 150, y: 20 }
const xLocation = await logo.getLocation('x')
console.log(xLocation); // outputs: 150
const yLocation = await logo.getLocation('y')
console.log(yLocation); // outputs: 20
});
戻り値
- <Object|Number>
return
: ページ上の要素のXおよびY座標{x:number, y:number}