Skip to main content

The Tauri plugin serves a subset of W3C WebDriver over HTTP from inside your app. BaseCase, sbrs and any other WebDriver client speak it for you; these pages document each route as the plugin’s code answers it, with raw HTTP requests you can send with cURL.

Base URL#

Every path in this reference follows http://127.0.0.1:4445/{token}; a session command follows /session/{sessionId}. When the endpoint starts, the app prints the whole URL on stderr:

tokenstringrequired#

The secret first segment of every path: SBRS_AUTOMATION_TOKEN, or a random one of 32 hexadecimal digits made when the app starts. A path that does not start with /{token} followed by / or its end answers 404 unknown command (the URL does not start with the token).

portinteger#

SBRS_AUTOMATION_PORT. If the port is taken (a second instance of the app, a Selenium container), the app runs without the endpoint and says so on stderr.

Default: "4445"

Warning

Give a WebDriver client the URL with the trailing slash. Clients join each command path (session, …) to the server URL as a relative URL, so without the slash the token is replaced and every request is refused with the URL does not start with the token.

The query string is ignored, and so are empty path segments (a doubled or a trailing slash).

Authentication#

There is no credential header. The endpoint is guarded instead:

  • it is on in debug builds only, unless SBRS_AUTOMATION turns it on (or off);
  • it listens on 127.0.0.1 only;
  • every path must start with the token;
  • a request with an Origin header is refused.
Originstring#

Must be absent. Browsers send it with every request a web page makes and WebDriver clients do not, so any request that has one answers 403 unknown error (requests from web pages are refused), whatever its path. This check comes before the token’s.

Requests#

  • The body is read as JSON whatever its Content-Type; an empty body counts as {}. A body that is not JSON answers 400 invalid argument (the body is not JSON: ...), on any route. Bodies are cut at 16 MiB.
  • The server answers one request at a time, on one thread: a long script or a navigation that waits for its page holds up the requests behind it.
  • Most commands run as an operation of the page script (bridge.js) in the app’s window, which has 30 seconds to answer (500 timeout, the page did not answer ... in time). Scripts get the session’s script timeout instead. The window commands and screenshots ask the native window, not the page.

Replies#

Every reply is JSON, with Content-Type: application/json; charset=utf-8. A command that succeeds answers 200 and its result under value (null for commands that return nothing). A command that fails answers the HTTP status of its W3C error code and an error object under value:

valueanyrequired#

The result of the command, or the error.

Element references#

An element travels as the W3C web element reference: an object with one key, element-6066-11e4-a52e-4f735466cecf, whose value is the element’s id.

The page script makes the ids (e, a counter, -, up to eight random characters) and keeps them for as long as the document lives: the same element always gets the same id. An element removed from the page answers 404 stale element reference. Once the window loads another document, the old ids answer 404 no such element (no element ... in this page).

Errors#

The status is the one the W3C specification gives each code. The codes the plugin produces, and when:

StatuserrorWhen
400invalid argumentA body that is not JSON; a missing or wrong field (url, using, value, script, text, the timeouts, the window rectangle, the frame id, the actions); an unknown locator strategy.
400invalid selectorA CSS selector or XPath the page cannot parse.
400element not interactableClicking an element that is not displayed; sending text while an alert or a confirm is recorded.
403unknown errorAny request with an Origin header.
404unknown commandA path without the token; a route the plugin does not serve (GET cookie is not supported).
404invalid session idNo session is open, or the id is not the current session’s.
404no such elementNothing matches; an element id the page does not know; a pointer move onto an element outside the current frame.
404stale element referenceThe element is no longer in the page.
404no such windowSwitching to a handle other than main; the app has no window.
404no such frameA frame that cannot be entered (cross-origin, sandboxed, not a frame, no such index), or a frame entered that is gone.
404no such alertReading the text with no dialog recorded.
500session not createdThe window did not load its page within 60 seconds, or the page could not be reset.
500timeoutA navigation’s page did not load within the page-load timeout; the page did not answer an operation within 30 seconds; WebKit did not draw a screenshot within 30 seconds.
500script timeoutA script ran past the session’s script timeout.
500javascript errorA script threw; the page failed an operation without a code.
500unsupported operationScreenshots on Windows and Linux; wheel input, pen and touch pointers, pointerCancel; answering a dialog other than the page was answered; text for a prompt that has opened.
500move target out of boundsA pointer move outside the viewport.
500unable to capture screenAn element with no area in view; WebKit gave no snapshot.
500unknown errorThe webview cannot be reached; the window refused a change; the page gave no rectangle for an element.

Commands never fail with unexpected alert open: dialogs are answered when they open (see User prompts).

Not served#

Any other route answers 404 unknown command, {METHOD} {path} is not supported: among them cookies, shadow roots, and opening or closing windows. Cookies are left out on purpose: on macOS the app’s page is tauri://localhost, where WKWebView keeps no cookies at all (document.cookie reads back empty after a write).

Badges#

Every command was written against the W3C specification and is checked by the plugin’s unit tests. On the pages that follow, Verified on macOS marks a command driven in a real app (the tauri-profile-manager example, macOS, Tauri 3.0.0-alpha.4), and Not run on a real app yet one that only the unit tests check. Nothing has been run on Windows or Linux yet.

Command groups#