Change the window rect. This is defined as a dictionary of the screenX, screenY, outerWidth and outerHeight attributes of the 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 in CSS pixels. To change the window react, you can either specify width and height, x and y or all properties together.

Usage

.setWindowRect({width, height, x, y}, [callback]);

Parameters

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.

callback
Optional
function

Optional callback function to be called when the command finishes.

Example

module.exports = {
  'demo test .setWindowRect()': function(browser) {

     // Change the screenX and screenY attributes of the window rect.
     browser.setWindowRect({x: 500, y: 500});

     // Change the width and height attributes of the window rect.
     browser.setWindowRect({width: 600, height: 300});

     // Retrieve the attributes
     browser.setWindowRect(function(result) {
       console.log(result.value);
     });
  },

  'setWindowRect ES6 demo test': async function(browser) {
     await browser.setWindowRect({
       width: 600,
       height: 300,
       x: 100,
       y: 100
     });
  }
}

See also

W3C WebDriver spec