.window.getRect() 建議編輯
擷取目前視窗的視窗矩形 - 大小和位置。
其 JSON 表示法如下
x
- 視窗的 screenX 屬性;y
- 視窗的 screenY 屬性;width
- outerWidth 屬性;height
- outerHeight 屬性。
所有屬性都以 CSS 像素為單位。
用法
.window.getRect([callback])
範例
module.exports = {
'get current window rect': function (browser) {
browser.window.getRect(function (result) {
console.log('Size of current window:', result.value.width, result.value.height);
console.log('Position of current window:', result.value.x, result.value.y);
});
},
'get current window rect using ES6 async/await': async function (browser) {
const {width, height, x, y} = await browser.window.getRect();
console.log('Size of current window:', width, height);
console.log('Position of current window:', x, y);
}
}
參數
名稱 | 類型 | 描述 |
---|---|---|
callback 選用 |
function | 呼叫時帶有結果值的回呼函式。 |
回傳
類型 | 描述 |
---|---|
* | 目前視窗的大小和位置。 |