// Type textawait testdriver.type('hello@example.com');// Type numbersawait testdriver.type(12345);// Type with custom delay (legacy syntax)await testdriver.type('slow typing', 500); // 500ms between each character// Type with options objectawait testdriver.type('text', { delay: 500 });
// Focus field and typeconst emailField = await testdriver.find('email input');await emailField.click();await testdriver.type('user@example.com');// Tab to next field and typeawait testdriver.pressKeys(['tab']);await testdriver.type('John Doe');// Type password securelyawait testdriver.pressKeys(['tab']);await testdriver.type('MySecureP@ssw0rd', { secret: true });
Field must be focusedTyping will only work if an input field is currently focused. If no field is focused, the text may be lost or trigger unexpected keyboard shortcuts.
const searchBox = await testdriver.find('search input');await searchBox.click();await testdriver.type('laptop computers');await testdriver.pressKeys(['enter']);// Wait for resultsawait new Promise(r => setTimeout(r, 2000));
Multi-Field Forms
// First fieldconst nameField = await testdriver.find('full name input');await nameField.click();await testdriver.type('Jane Smith');// Navigate with Tabawait testdriver.pressKeys(['tab']);await testdriver.type('jane.smith@example.com');await testdriver.pressKeys(['tab']);await testdriver.type('+1-555-0123');await testdriver.pressKeys(['tab']);await testdriver.type('123 Main Street');
Text Editors
const editor = await testdriver.find('text editor area');await editor.click();await testdriver.type('# My Document', 100);await testdriver.pressKeys(['enter', 'enter']);await testdriver.type('This is the first paragraph.', 50);
// Fast typing (100ms delay)await testdriver.type('quick entry', 100);// Normal typing (250ms - default)await testdriver.type('standard speed');// Slow typing (500ms delay) - useful for fields with live validationawait testdriver.type('slow and steady', 500);// Very slow (1000ms delay) - for problematic fieldsawait testdriver.type('one by one', 1000);
Some applications with live validation or autocomplete may require slower typing speeds to avoid race conditions.