Change or get 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

.windowRect({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 .windowRect()': function(browser) {

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

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

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

  'windowRect ES6 demo test': async function(browser) {
     const resultValue = await browser.windowRect();
     console.log('result value', resultValue);
  }
}

W3C WebDriver spec