Skip to main content

Desktop Driver Window

Desktop Driver Window

Current window object can be retrieved from driver using the method:

Window window = driver.getActiveWindow();


DesktopWindow supports only the following methods:

Maximize

Maximize the current window.

driver.getActiveWindow().maximize();

Focus

Calling of this method is focusing on current window.

((DesktopWindow) driver.getActiveWindow()).focus();

Get Size

Returns the Dimension object with the "width" and "height" properties

Dimension windowDimension = driver.getActiveWindow().getSize();

System.out.println("Current window size is: " + windowDimension.getWidth() + "x" + windowDimension.getHeight());

Get Position

Returns the current position of the window on screen. The value is returned as "Point" object with "x" and "y" properties.

Point windowPosition = driver.getActiveWindow().getPosition();

System.out.println("Current window position is: " + windowPosition.getX() + "x" + windowPosition.getY());