Set Window Rect - WebDriver - MDN
Set Window Rect - WebDriver - MDN
Syntax
Method URI template
POST /session/{session id}/window/rect
URL parameters
session id
Horizontal position of the window , which equivalent to Window.screenX . Must be a number in the −(2^31) to 2^31 − 1 range, null, or undefined.
y
Vertical position of the window , which is equivalent to Window.screenY . Must be a number in the −(2^31) to 2^31 − 1 range, null, or undefined.
width
Outer width of the window , which is equivalent to Window.outerWidth . Must be a number in the 0 to 2^31 − 1 range, null, or undefined.
height
Outer width of the window , which is equivalent to Window.outerHeight . Must be a number in the 0 to 2^31 − 1 range, null, or undefined.
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
Width of outer bounds of the operating system window associated with window , equivalent to Window.outerWidth .
height
Height of the outer bounds of the operating system window associated with window , equivalent to Window.outerHeight .
Errors
Invalid argument
If any of the fields in the WindowRect payload object do not meet the type or bounds constraints, or if only one of the x / y pair or width / height pair fields are specified.
Invalid session ID
Session does not exist.
No such window
If the window has been closed.
Unexpected alert open
A user prompt, such as window.alert , blocks execution of command until it is dealt with.
Unsupported operation
https://developer.mozilla.org/en-US/docs/Web/WebDriver/Commands/SetWindowRect 1/2
11/11/23, 01:13 Set Window Rect - WebDriver | MDN
If the driver does not support altering the window's size or position. This is usually the case on mobile devices, where the browser has a set dimension and cannot be moved around on
the screen.
You can inspect the setWindowRect capability to tell if the device supports this command.
Specifications
Specification
WebDriver
# dfn-set-window-rect
Browser compatibility
Report problems with this compatibility data on GitHub
tenretnI gnusmaS
diordnA emorhC
diordnA arepO
SOi no irafaS
emorhC
xoferiF
arepO
irafaS
egdE
Chrome 65 Edge 79 Firefox 55 Opera No Safari No Chrome No Firefox No Opera No Safari No Samsung No W
SetWindowRect Android for Android on Internet
Android iOS
Tip: you can click/tap on a cell for more information.
Full support No support See implementation notes.
See also
WebWindow object
Associated commands:
Get Window Rect
Get Window Handle
Get Window Handles
Close Window
This page was last modified on Jun 29, 2023 by MDN contributors.
https://developer.mozilla.org/en-US/docs/Web/WebDriver/Commands/SetWindowRect 2/2