getViewportSize

Get viewport size of the current browser window.

Usage

1
client.getViewportSize(property).then(callback);

Parameters

Param Type Details
property String if “width” or “height” is set it returns only that property

Example

getSource.js
1
2
3
4
5
6
7
8
9
10
11
client
.url('http://webdriver.io')
.getViewportSize().then(function(size) {
console.log(size); // outputs: {width: 1024, height: 768}
})
.getViewportSize('width').then(function(size) {
console.log(size); // outputs: 1024
})
.getViewportSize('height').then(function(size) {
console.log(size); // outputs: 768
});

Uses