The Get Window Rect command of the WebDriver API returns the size and position of the given WebElement. Many WebDriver clients present separate API methods for getting an element's location and dimensions, but as an optimization they both use this primitive.
The command operates on the currently selected window, and returns size and position of the operating system window. The returned WindowRect can be used as input for the Set Window Rect command, which is for manipulating a window's position and dimensions.
| Method | URI template |
|---|---|
GET | /session/{session id}/window/rect |
session idIdentifier of the session.
The response payload is a WindowRect:
xHorizontal position of the operating system window associated with window, equivalent to Window.screenX.
yVertical position of the operating system window associated with window, equivalent to Window.screenY.
widthWidth of outer bounds of the operating system window associated with window, equivalent to Window.outerWidth.
heightHeight of the outer bounds of the operating system window associated with window, equivalent to Window.outerHeight.
invalid session idSession does not exist.
unexpected alert openA user prompt, such as window.alert, blocks execution of command until it is dealt with.