メインコンテンツにスキップ
バージョン: 22.5.0

Frame.type() メソッド

テキスト内の各文字に対して、keydownkeypress/input、および keyup イベントを送信します。

シグネチャ:

class Frame {
type(
selector: string,
text: string,
options?: Readonly<KeyboardTypeOptions>
): Promise<void>;
}

パラメーター

パラメーター説明
selectorstring入力する要素のセレクター。複数ある場合は最初のものが使用されます。
textstring要素に入力するテキスト
optionsReadonly<KeyboardTypeOptions>(オプション) 1つのオプション delay を受け取り、キー押下間の待ち時間をミリ秒単位で設定します。デフォルトは 0 です。

戻り値

Promise<void>

備考

ControlArrowDown のような特殊キーを押すには、Keyboard.press() を使用します。

await frame.type('#mytextarea', 'Hello'); // Types instantly
await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user