* Type text into the element * @param {string} text Text to type * @param {Object} options Type options * @returns {Promise }
(text, options = {})
| 242 | * @returns {Promise<void>} |
| 243 | */ |
| 244 | async type(text, options = {}) { |
| 245 | switch (this.helperType) { |
| 246 | case 'playwright': |
| 247 | // Playwright Locator objects use fill() instead of type() |
| 248 | if (this.element.fill) { |
| 249 | return this.element.fill(text, options) |
| 250 | } |
| 251 | return this.element.type(text, options) |
| 252 | case 'webdriver': |
| 253 | return this.element.setValue(text) |
| 254 | case 'puppeteer': |
| 255 | await this.element.evaluate(el => { el.value = '' }) |
| 256 | return this.element.type(text, options) |
| 257 | default: |
| 258 | throw new Error(`Unsupported helper type: ${this.helperType}`) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Run a function in the browser with this element as the first argument. |