Get Window Rect
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheGet Window Rectcommand of theWebDriver API returns the size and position of the givenWebElement. ManyWebDriver 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 returnedWindowRect can be used as input for theSet Window Rect command, which is for manipulating a window's position and dimensions.
In this article
Syntax
| Method | URI template |
|---|---|
GET | /session/{session id}/window/rect |
URL parameters
session idIdentifier of the session.
Response
The response payload is aWindowRect:
xHorizontal position of the operating system window associated with
window, equivalent toWindow.screenX.yVertical position of the operating system window associated with
window, equivalent toWindow.screenY.widthWidth of outer bounds of the operating system window associated with
window, equivalent toWindow.outerWidth.heightHeight of the outer bounds of the operating system window associated with
window, equivalent toWindow.outerHeight.
Errors
- Invalid session ID
Session does not exist.
- Unexpected alert open
A user prompt, such as
window.alert, blocks execution of command until it is dealt with.
Specifications
| Specification |
|---|
| WebDriver> # get-window-rect> |
Browser compatibility
See also
- WebWindow
- Associated commands: