Mouse & Keyboard
Standalone Mouse and Keyboard controllers for low-level input that isn't tied to a specific element. Use these for drag-and-drop, keyboard shortcuts, and coordinate-based interactions.
Mouse
Move
Click
Moves to the coordinates and clicks:
Down / Up
Press and release the mouse button separately:
Drag
Drag from one point to another with smooth movement:
Performs 10 intermediate move steps with 10ms delay between each.
Keyboard
Press
Key down + key up:
Down / Up
Press and release keys separately (for key combinations):
Type
Type text character by character with key events:
InsertText
Insert text instantly without key events:
When to Use
| Scenario | Use |
|---|---|
| Click a button | el.Click() or page.Click("#btn") |
| Click at coordinates | page.Mouse().Click(x, y) |
| Drag and drop | page.Mouse().DragTo(...) |
| Type in a field | el.Type("text") or page.Type("#input", "text") |
| Keyboard shortcut | page.Keyboard().Down("Control"); page.Keyboard().Press("c"); page.Keyboard().Up("Control") |
| Paste text | page.Keyboard().InsertText("text") |