Input¶
InputModule ¶
Module for simulating user input (keyboard, mouse, scroll).
Commands
- perform_actions — executes a sequence of input actions
- release_actions — cancels all in-progress actions
- set_files — selects files on an
Example
actions = [ InputSource( type="pointer", id="mouse", actions=[ {"type": "pointerMove", "x": 100, "y": 200}, {"type": "pointerDown", "button": 0}, {"type": "pointerUp", "button": 0}, ], ), ] await client.input.perform_actions(context, actions)
Source code in bidiwave/modules/input.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
perform_actions
async
¶
Executes a sequence of input actions in a context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID where to execute actions. |
required |
actions
|
list[InputSource]
|
List of InputSource, each representing a virtual device (keyboard, mouse, wheel) with its actions. |
required |
Source code in bidiwave/modules/input.py
release_actions
async
¶
Cancels all in-progress input actions for a context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
Source code in bidiwave/modules/input.py
set_files
async
¶
Selects files on an element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
element
|
str
|
Shared ID of the file input element. |
required |
files
|
list[str]
|
List of absolute file paths to select. |
required |
Source code in bidiwave/modules/input.py
click
async
¶
click(context: BrowsingContext | str, x: int | float, y: int | float, button: int = 0, duration: int = 0) -> None
Convenience: click at coordinates (x, y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
x
|
int | float
|
X coordinate relative to the viewport. |
required |
y
|
int | float
|
Y coordinate relative to the viewport. |
required |
button
|
int
|
0 = left, 1 = middle, 2 = right. |
0
|
duration
|
int
|
Press duration in ms. |
0
|
Source code in bidiwave/modules/input.py
double_click
async
¶
Convenience: double click at coordinates (x, y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
x
|
int | float
|
X coordinate relative to the viewport. |
required |
y
|
int | float
|
Y coordinate relative to the viewport. |
required |
Source code in bidiwave/modules/input.py
type_text
async
¶
Convenience: types text key by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
text
|
str
|
Text to type. |
required |
Source code in bidiwave/modules/input.py
press_key
async
¶
Convenience: presses and releases a key.
Uses the protocol key format (e.g: "Enter", "Tab", "Escape", or a literal character like "a").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
key
|
str
|
Key to press (e.g: "Enter", "a", "Escape"). |
required |
Source code in bidiwave/modules/input.py
scroll
async
¶
scroll(context: BrowsingContext | str, delta_x: int = 0, delta_y: int = 0, x: int = 0, y: int = 0, duration: int | None = None) -> None
Convenience: mouse wheel scroll.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
delta_x
|
int
|
Horizontal scroll amount (positive = right). |
0
|
delta_y
|
int
|
Vertical scroll amount (positive = down). |
0
|
x
|
int
|
X coordinate of the pointer during scroll. |
0
|
y
|
int
|
Y coordinate of the pointer during scroll. |
0
|
duration
|
int | None
|
Scroll duration in ms. |
None
|
Source code in bidiwave/modules/input.py
drag_and_drop
async
¶
drag_and_drop(context: BrowsingContext | str, start_x: int | float, start_y: int | float, end_x: int | float, end_y: int | float, duration: int = 100) -> None
Convenience: drag and drop from (start_x, start_y) to (end_x, end_y).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
BrowsingContext | str
|
BrowsingContext or context ID. |
required |
start_x
|
int | float
|
Initial X coordinate. |
required |
start_y
|
int | float
|
Initial Y coordinate. |
required |
end_x
|
int | float
|
Final X coordinate. |
required |
end_y
|
int | float
|
Final Y coordinate. |
required |
duration
|
int
|
Movement duration in ms. |
100
|
Source code in bidiwave/modules/input.py
Action sources¶
Actions are grouped by input device type (InputSource):
"pointer"— mouse, pen, or touch (move, down, up)"key"— keyboard (press, release)"wheel"— scroll (horizontal and vertical)
Convenience methods¶
Click¶
Double click¶
Type text¶
Press a key¶
Scroll¶
Drag and drop¶
await client.input.drag_and_drop(
context,
start_x=100, start_y=100,
end_x=300, end_y=300,
duration=200,
)
Custom action sequences¶
For fine-grained control, build InputSource objects directly:
from bidiwave import InputSource
actions = [
InputSource(
type="pointer",
id="mouse",
actions=[
{"type": "pointerMove", "x": 100, "y": 200},
{"type": "pointerDown", "button": 0},
{"type": "pointerUp", "button": 0},
],
),
InputSource(
type="key",
id="keyboard",
actions=[
{"type": "key", "value": "a"},
{"type": "key", "value": "b"},
{"type": "key", "value": "c"},
],
),
]
await client.input.perform_actions(context, actions)
Set files¶
Select files on an <input type="file"> element: