Change the window rect - size and position of the current window.

Its JSON representation is the following:

  • x - window's screenX attribute;
  • y - window's screenY attribute;
  • width - outerWidth attribute;
  • height - outerHeight attribute.

All attributes are in CSS pixels.

To change the window rect, you can either specify width and height together, x and y together, or all properties together.


                    .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


Name Type description
options Object

An object specifying either width and height, x and y, or all together to set properties for the window rect.


Optional callback function to be called when the command finishes.

See also

W3C WebDriver spec