Skip to content

element.type

element.type(keys: string|string[], options?: Object): Promise<void>

Section titled “element.type(keys: string|string[], options?: Object): Promise<void>”

Simulates typing on the element by dispatching key events. This method is compatible with input elements or any elements that have key event listeners such as keydown, keyup, or keypress.

  • keys: The keys to type. Can be a string or an array of characters.
  • options.altKey: Indicates if the Alt key is pressed.
  • options.ctrlKey: Indicates if the Ctrl key is pressed.
  • options.metaKey: Indicates if the Meta key is pressed.
  • options.shiftKey: Indicates if the Shift key is pressed.
  • Returns a promise that resolves when the action is complete.
describe('Test script', function () {
it('Test 1', async () => {
const element = await gf.get('.my-element');
await element.type('text');
const input = await gf.get('input');
await input.type('text');
});
});