* {{> type }}
(keys, delay = null)
| 2254 | * {{> type }} |
| 2255 | */ |
| 2256 | async type(keys, delay = null) { |
| 2257 | await checkFocusBeforeType(this) |
| 2258 | |
| 2259 | // Always use page.keyboard.type for any string (including single character and national characters). |
| 2260 | if (!Array.isArray(keys)) { |
| 2261 | keys = keys.toString() |
| 2262 | const typeDelay = typeof delay === 'number' ? delay : this.options.pressKeyDelay |
| 2263 | await this.page.keyboard.type(keys, { delay: typeDelay }) |
| 2264 | return |
| 2265 | } |
| 2266 | |
| 2267 | // For array input, treat each as a key press to keep working combinations such as ['Control', 'A'] or ['T', 'e', 's', 't']. |
| 2268 | for (const key of keys) { |
| 2269 | await this.page.keyboard.press(key) |
| 2270 | if (delay) await this.wait(delay / 1000) |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | /** |
| 2275 | * {{> fillField }} |
no test coverage detected