Appearance
Variable: typeByXPath()
ts
const typeByXPath: (ctx: Context, selector: string, value: string, options: TypeOptions & WaitForSelectorOptions) => Promise<void> = type;Defined in: src/keyboard/index.ts:259
Type text into a form field after existing content.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
selector | string | CSS selector. |
value | string | Text to type into the field. |
options | TypeOptions & WaitForSelectorOptions | Typing behavior and wait options. |
Returns
Promise<void>
Remarks
Fire an event for each character. To clear the field first, use fill.
Examples
ts
// Type a message in a chat box
await type(ctx, '#chat-input', 'Hey, are we still on for Friday?');ts
// Type slowly into a search field and blur when done
await type(ctx, '#search', 'vintage guitars', {
delay: 80,
clear: true,
blur: true,
});Deprecated
Use type instead.
Type text into a form field by XPath.
Param
Context object.
Param
XPath selector.
Param
Text to type into the field.
Param
Typing behavior and wait options.