* Select all content in the focused field and delete it via keyboard input. * Sends Ctrl+A and Meta+A (so it works across platforms) followed by Backspace. * @returns {Promise }
()
| 329 | * @returns {Promise<void>} |
| 330 | */ |
| 331 | async selectAllAndDelete() { |
| 332 | switch (this.helperType) { |
| 333 | case 'playwright': |
| 334 | await this.helper.page.keyboard.press('Control+a').catch(() => {}) |
| 335 | await this.helper.page.keyboard.press('Meta+a').catch(() => {}) |
| 336 | await this.helper.page.keyboard.press('Backspace') |
| 337 | return |
| 338 | case 'puppeteer': |
| 339 | for (const mod of ['Control', 'Meta']) { |
| 340 | try { |
| 341 | await this.helper.page.keyboard.down(mod) |
| 342 | await this.helper.page.keyboard.press('KeyA') |
| 343 | await this.helper.page.keyboard.up(mod) |
| 344 | } catch (e) {} |
| 345 | } |
| 346 | await this.helper.page.keyboard.press('Backspace') |
| 347 | return |
| 348 | case 'webdriver': { |
| 349 | const b = this.helper.browser |
| 350 | await b.keys(['Control', 'a']).catch(() => {}) |
| 351 | await b.keys(['Meta', 'a']).catch(() => {}) |
| 352 | await b.keys(['Backspace']) |
| 353 | return |
| 354 | } |
| 355 | default: |
| 356 | throw new Error(`Unsupported helper type: ${this.helperType}`) |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | /** |
| 361 | * Treat this element as an iframe; invoke `fn` with a WebElement wrapping |