Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/web/webdriver/commands/getwindowrect/index.md
6532 views
---
title: Get Window Rect slug: Web/WebDriver/Commands/GetWindowRect browser-compat: webdriver.commands.GetWindowRect
---

{{QuickLinksWithSubpages("/en-US/docs/Web/WebDriver/Commands")}}

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.

Syntax

MethodURI template
GET/session/{session id}/window/rect

URL parameters

  • session id

    • : Identifier of the session.

Response

The response payload is a WindowRect:

  • x

    • : Horizontal position of the operating system window associated with window, equivalent to Window.screenX.

  • y

    • : Vertical position of the operating system window associated with window, equivalent to Window.screenY.

  • width

  • height

Errors

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also