Skip to main content

Module input

Module input 

Source
Expand description

Native CDP input and geometry for ref-based interaction.

Every function here works on an already-attached flat session (see crate::session::cdp_session::with_page_session) and a CDP backendDOMNodeId, which is what an element ref resolves to. Clicks go through Input.dispatchMouseEvent at the element’s centre in viewport CSS pixels — the coordinate space DOM.getContentQuads already reports in, so no device-pixel-ratio maths is involved. Text goes through Input.insertText, which fires the same beforeinput/input events a paste does (Playwright’s fill does the same).

Deliberately not done in v1: occlusion checks (a click on a covered element lands on the overlay), auto-waiting, and Page.bringToFront (input works on background tabs, and the project keeps automated tabs in the background).

Structs§

Point
A point in viewport CSS pixels.

Functions§

click
Left-click the node’s centre.
document_token
The Document node’s backendNodeId: changes on every navigation, so it identifies “the document the refs were taken from”.
drag
Pointer-event drag from one node’s centre to another’s. HTML5 native drag-and-drop (draggable) needs Input.setInterceptDrags; not in v1.
hover
Move the pointer over the node’s centre.
node_center
Scroll the node into view and return its clickable centre.
node_clip_rect
Border box of the node in document coordinates, the same contract as crate::dom::scripts::GET_CLIP_RECT_JS, for element screenshots.
pick_point
Pick the centre of the first quad with a visible area after clipping to the viewport. Mirrors Puppeteer’s clickablePoint.
press_enter
Press and release Enter on the focused element. text: "\r" on the keyDown is what makes Chromium synthesise the keypress and submit forms, matching Puppeteer.
type_text
Focus the node, replace its current content with text, and optionally press Enter. press_sequentially inserts one character per event for inputs that react to each keystroke.