type
Type text into an input element. Supports three modes: replace, append, and paste.
Signature
await utils.type(selector, text, options?)Parameters
| Param | Type | Default | Description |
|---|---|---|---|
selector | string | — | CSS selector or XPath |
text | string | — | Text to type |
options.mode | "replace" | "append" | "paste" | "replace" | Typing mode |
options.delay | number | 50 | Delay between keystrokes (ms). Ignored in paste mode |
options.waitTimeout | number | 0 | Max wait time for element (ms). Default: instant |
options.frame | Frame | — | Optional frame to search within |
Modes
| Mode | Behavior |
|---|---|
replace | Triple-click to select all → type new text (clears old value) |
append | Type without clearing — adds to existing text |
paste | Set value directly via JS (fast, no keystroke simulation) |
Examples
// Replace mode (default) — clear then type
await utils.type("#email", "user@test.com");
// Append — add text to existing value
await utils.type("#tags", ", new-tag", { mode: "append" });
// Paste — set value instantly (good for long strings)
await utils.type("#private-key", "0xABCD...", { mode: "paste" });
// Wait for element before typing
await utils.type("#lazy-input", "hello", { waitTimeout: 8000 });Error Handling
Throws if the element is not found.
Last updated on