Skip to content

Function: type()

ts
function type(
   ctx: Context, 
   selector: string, 
   value: string, 
options?: TypeOptions & WaitForSelectorOptions): Promise<void>;

Defined in: src/keyboard/index.ts:175

Type text into a form field after existing content.

Parameters

ParameterTypeDescription
ctxContextContext object.
selectorstringCSS selector.
valuestringText to type into the field.
optionsTypeOptions & WaitForSelectorOptionsTyping 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,
});

Matterway Assistant SDK Documentation