Skip to content

Commit 9f5f2f4

Browse files
DavertMikclaude
andcommitted
fix: WebDriver v9 frame switching + newline handling
Use switchFrame() instead of removed switchToFrame/switchToParentFrame. Split typed text on \n and emit Enter keypress (\uE007) between segments so multi-paragraph content reaches Trix and other keystroke-driven editors. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e14ef4e commit 9f5f2f4

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

lib/element/WebElement.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,15 @@ class WebElement {
306306
case 'playwright':
307307
case 'puppeteer':
308308
return this.helper.page.keyboard.type(s, options)
309-
case 'webdriver':
310-
return this.helper.browser.keys(s)
309+
case 'webdriver': {
310+
const ENTER = '\uE007'
311+
const parts = s.split('\n')
312+
for (let i = 0; i < parts.length; i++) {
313+
if (parts[i]) await this.helper.browser.keys(parts[i])
314+
if (i < parts.length - 1) await this.helper.browser.keys(ENTER)
315+
}
316+
return
317+
}
311318
default:
312319
throw new Error(`Unsupported helper type: ${this.helperType}`)
313320
}
@@ -364,12 +371,12 @@ class WebElement {
364371
}
365372
case 'webdriver': {
366373
const browser = this.helper.browser
367-
await browser.switchToFrame(this.element)
374+
await browser.switchFrame(this.element)
368375
try {
369376
const body = await browser.$('body')
370377
return await fn(new WebElement(body, this.helper))
371378
} finally {
372-
await browser.switchToParentFrame()
379+
await browser.switchFrame(null)
373380
}
374381
}
375382
default:

0 commit comments

Comments
 (0)