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
Runs W3C actions tick by tickA tick is the i-th action of every input source, run together.:
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.
The current session’s id.
The input sources.
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.
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:
| Code | Key | Code | Key |
|---|---|---|---|
\uE003 | Backspace | \uE00C | Escape |
\uE004 | Tab | \uE00D | Space (" ") |
\uE006, \uE007 | Enter | \uE017 | Delete |
\uE008 | Shift | \uE03D | Meta |
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
| Status | error | When |
|---|---|---|
| 400 | invalid argument | actions 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. |
| 404 | no such element, stale element reference | A move’s origin element is unknown, gone, or not in the current frame. |
| 404 | no such frame | The frame entered is gone or no longer same-origin. |
| 500 | unsupported operation | Wheel input, a pen or touch pointer, pointerCancel. |
| 500 | move target out of bounds | A move that ends outside the viewport. |
Release actions#
DELETE /session/{sessionId}/actions
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.
The current session’s id.
null.