* Type characters via the page/browser keyboard into the focused element. * Unlike `type()`, this does not call `.fill()`/`.setValue()`, so it works * with contenteditable nodes, iframe bodies, and editor-owned hidden textareas. * @param {string} text Text to send * @param {Object} [opti
(text, options = {})
| 304 | * @returns {Promise<void>} |
| 305 | */ |
| 306 | async typeText(text, options = {}) { |
| 307 | const s = String(text) |
| 308 | switch (this.helperType) { |
| 309 | case 'playwright': |
| 310 | case 'puppeteer': |
| 311 | return this.helper.page.keyboard.type(s, options) |
| 312 | case 'webdriver': { |
| 313 | const ENTER = '\uE007' |
| 314 | const parts = s.split('\n') |
| 315 | for (let i = 0; i < parts.length; i++) { |
| 316 | if (parts[i]) await this.helper.browser.keys(parts[i]) |
| 317 | if (i < parts.length - 1) await this.helper.browser.keys(ENTER) |
| 318 | } |
| 319 | return |
| 320 | } |
| 321 | default: |
| 322 | throw new Error(`Unsupported helper type: ${this.helperType}`) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Select all content in the focused field and delete it via keyboard input. |