Skip to main content

Actions are simulated in the page with DOM events at the pointer’s place in the current frame, not OS-level input: the mouse and the keyboard are never used. Paths follow http://127.0.0.1:4445/{token}; see the overview for the reply format and the errors.

Perform actions#

POST /session/{sessionId}/actions

Verified on macOS: double click, hover, Space, Enter Not run on a real app yet: right click, drag, Backspace

Runs W3C actions tick by tick: one keyboard (keyDown, keyUp), mouse pointers (pointerMove from the viewport, the pointer or an element, pointerDown, pointerUp with buttons 0 to 4) and pauses. The whole body is checked before anything runs, so a body with one wrong or unsupported action runs nothing. Each tick’s input is dispatched at once; the tick then lasts as long as its longest pause or pointer move (a move does not glide: the pointer jumps, then the time passes). Other actions may carry a duration, which is ignored.

Right clicks, drags and Backspace are checked only by the tests of src/bridge.js in a fake page under Node.js (tests/bridge.test.mjs), not in a webview.

sessionIdstringrequired#

The current session’s id.

actionsobject[]required#

The input sources.

valuenullrequired#

null, once the last tick is over.

What the page sees#

Pointer moves

A move onto an element out of view scrolls it into view first, at once even when the page sets scroll-behavior: smooth (as clicks and element screenshots do). A move that ends outside the viewport answers 500 move target out of bounds. When the element under the pointer changes, the old one gets pointerout, pointerleave, mouseout and mouseleave, the new one pointerover, pointerenter, mouseover and mouseenter; then the element under the pointer gets pointermove and mousemove.

Buttons

A press sends pointerdown and mousedown, and focuses what it lands on (or what holds that). A release sends pointerup and mouseup, then click with its count for the left button, and dblclick for two presses on the same element within 500 ms; the other buttons get auxclick, and the right one contextmenu too. A cancelled pointerdown holds back the mousedown and the focus.

Keys

Key events go to the focused element of the current frame, with shiftKey, ctrlKey, altKey and metaKey set while those keys are held. Printable keys type (through execCommand, so the page sees beforeinput and input), not while Control or Meta is held; Backspace and Delete delete; Enter submits a form field’s form, adds a line to a textarea or a paragraph to an editable element, and clicks a button or a link. A cancelled keydown types nothing.

What it cannot do

Because the events are not the OS’s, CSS :hover does not apply and HTML drag and drop (draggable) does not start. Wheel input, pen and touch pointers and pointerCancel answer unsupported operation.

Keys#

A WebDriver key code is turned into the key name W3C gives it; a few:

CodeKeyCodeKey
\uE003Backspace\uE00CEscape
\uE004Tab\uE00DSpace (" ")
\uE006, \uE007Enter\uE017Delete
\uE008Shift\uE03DMeta

The arrows, Home, End, Page Up and Down, Insert, the digits of the number pad, F1 to F12 and the right-hand modifier codes are mapped the same way.

Errors

StatuserrorWhen
400invalid argumentactions is not an array; a source without id, type or actions; an unknown source or action type; a key action without a key; a button outside 0 to 4; a wrong origin, x, y or duration.
404no such element, stale element referenceA move’s origin element is unknown, gone, or not in the current frame.
404no such frameThe frame entered is gone or no longer same-origin.
500unsupported operationWheel input, a pen or touch pointer, pointerCancel.
500move target out of boundsA move that ends outside the viewport.

Release actions#

DELETE /session/{sessionId}/actions

Not run on a real app yet

Lets go of the keys and buttons still held, the last pressed first, as a keyUp or a pointerUp would (with the events those send), then forgets the input state (the pointers’ places too). If the frame entered is gone, it only forgets.

sessionIdstringrequired#

The current session’s id.

valuenullrequired#

null.