.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
});
}
}
参数
| 名称 | 类型 | 描述 |
|---|---|---|
选项 |
对象 | 一个对象,指定 |
回调可选 |
函数 | 命令完成后要调用的可选回调函数。 |