Skip to main content

The endpoint drives one window: the one labelled main, or else another window of the app. Its handle is always main. The rectangle comes from the native window, not the page, which cannot tell: WKWebView reports outerWidth and outerHeight as 0. Paths follow http://127.0.0.1:4445/{token}; see the overview for the reply format and the errors.

Every command that answers a rectangle answers the window’s outer rectangle in CSS pixels, rounded to whole pixels (a scale factor such as 1.5 gives fractions, and clients read integers):

valueobject#

Opening and closing windows are not served (404 unknown command).

Get window handle#

GET /session/{sessionId}/window

sessionIdstringrequired#

The current session’s id.

valuestringrequired#

Always main.

Get window handles#

GET /session/{sessionId}/window/handles

sessionIdstringrequired#

The current session’s id.

valuestring[]required#

Always ["main"].

Switch to window#

POST /session/{sessionId}/window

Accepts the one handle and changes nothing.

sessionIdstringrequired#

The current session’s id.

handlestringrequired#

main.

valuenullrequired#

null.

Errors

StatuserrorWhen
404no such windowAny other handle, or none (the app has one window, `main`).

Get window rect#

GET /session/{sessionId}/window/rect

Verified on macOS

The window’s rectangle as it is now.

sessionIdstringrequired#

The current session’s id.

Set window rect#

POST /session/{sessionId}/window/rect

Verified on macOS

Tauri only queues a change of the window for the main thread, and the system applies it a little later (leaving full screen is an animation, over which a new size is lost). So Set Window Rect first brings the window back to its normal state, as WebDriver asks: out of full screen, not maximized, not minimized (a maximized window would otherwise ignore the new size). It waits until the window has left each state and its frame has stopped moving; then moves and resizes it; then waits until the window has the size and the place and keeps its rectangle, asking again every quarter of a second if a request was lost, and giving up after two seconds.

Normally this takes well under a second. The waits are bounded, not short: a window that does not leave a state is waited for up to three seconds (and then used as it is), so a command can take about five seconds at worst for one state change, more if the window goes through several states. The answer is the rectangle the window has then, which can differ from the one asked for: the system keeps a window below the menu bar (a window lower than asked counts as placed) and may refuse a size. Sizes within one pixel count as reached. Tauri sizes the inside of a window and WebDriver the outside, so the plugin takes off the frame as it is at that moment.

sessionIdstringrequired#

The current session’s id.

xnumber | null#

The left edge, from -2147483648 to 2147483647. Missing or null keeps it.

ynumber | null#

The top edge, from -2147483648 to 2147483647. Missing or null keeps it.

widthnumber | null#

The outer width, from 0 to 2147483647. Missing or null keeps it.

heightnumber | null#

The outer height, from 0 to 2147483647. Missing or null keeps it.

With none of the four, the command only brings the window back to its normal state.

Errors

StatuserrorWhen
400invalid argumentA value out of range or not a number. Nothing is changed.
404no such windowThe app has no window.
500unknown errorThe window refused a change (the window refused: ...).

Maximize window#

POST /session/{sessionId}/window/maximize

Takes the window out of full screen and back from the dock first, then maximizes it, waits for the state (up to three seconds) and for the frame to stop moving (up to two), and answers the rectangle then.

sessionIdstringrequired#

The current session’s id.

Minimize window#

POST /session/{sessionId}/window/minimize

Minimizes the window, waits for the state the same way, and answers the rectangle then.

sessionIdstringrequired#

The current session’s id.

Fullscreen window#

POST /session/{sessionId}/window/fullscreen

Brings the window back from the dock first, makes it full screen, waits for the state the same way, and answers the rectangle then.

sessionIdstringrequired#

The current session’s id.

Tip

If a resize does not stick, start the app with SBRS_AUTOMATION_TRACE_WINDOW=1. Each window command then prints the window’s state on stderr before it asks for a change, after, and when it answers: what Tauri reports and, on macOS, what the NSWindow says (style mask, isZoomed, frame, content view, screen).