現在のウィンドウのサイズと位置(ウィンドウ矩形)を変更します。

そのJSON表現は以下の通りです。

  • x - ウィンドウのscreenX属性;
  • y - ウィンドウのscreenY属性;
  • width - outerWidth属性;
  • height - outerHeight属性。

すべての属性はCSSピクセル単位です。

ウィンドウ矩形を変更するには、widthheightを一緒に指定するか、xyを一緒に指定するか、またはすべてのプロパティを一緒に指定します。

使用方法

                    .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 オブジェクト

ウィンドウ矩形のプロパティを設定するためのwidthheightxy、またはすべてを一緒に指定するオブジェクト。

callback
オプション
関数

コマンドが完了したときに呼び出されるオプションのコールバック関数。

参照

W3C WebDriver仕様