.window.setRect() 建議編輯
更改目前視窗的 視窗矩形 - 大小和位置。
其 JSON 表示法如下
x
- 視窗的 screenX 屬性;y
- 視窗的 screenY 屬性;width
- outerWidth 屬性;height
- outerHeight 屬性。
所有屬性均以 CSS 像素為單位。
若要變更視窗矩形,您可以一起指定 width
和 height
,一起指定 x
和 y
,或一起指定所有屬性。
用法
.window.setRect({width, height, x, y}, [callback])
範例
module.exports = {
'set current window rect': function (browser) {
// Change the screenX and screenY attributes of the window rect.
browser.window.setRect({x: 500, y: 500});
// Change the outerWidth and outerHeight attributes of the window rect.
browser.window.setRect({width: 600, height: 300});
},
'set current window rect using ES6 async/await': async function (browser) {
// Change all attributes of the window rect at once.
await browser.window.setRect({
width: 600,
height: 300,
x: 100,
y: 100
});
}
}
參數
名稱 | 類型 | 描述 |
---|---|---|
options |
Object | 一個物件,指定 |
callback 可選 |
function | 命令完成時呼叫的可選回呼函數。 |