Skip to content

Fix newline characters not being typed into textareas - #61

Closed
kevinsimler wants to merge 2 commits into
VibiumDev:mainfrom
kevinsimler:textarea-newlines
Closed

Fix newline characters not being typed into textareas#61
kevinsimler wants to merge 2 commits into
VibiumDev:mainfrom
kevinsimler:textarea-newlines

Conversation

@kevinsimler

Copy link
Copy Markdown
Contributor

WebDriver BiDi requires carriage return (\r) to produce the Enter key, not newline (\n). Text containing \n was being typed without line breaks / line breaks were being dropped.

  • Add NormalizeKeyChar helper in internal/bidi/keys.go
  • Apply conversion in both input.go (CLI) and router.go (WebSocket API)
  • Add newline tests for JS async API and CLI

@hugs

hugs commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

to fix this issue, should we be sending \uE006 instead? including a link to where to relavent sections of the WebDriver or WebDriver BiDi spec would also be helpful to folks reading this later.

WebDriver BiDi requires carriage return (\r) to produce the Enter key,
not newline (\n). Text containing \n was being typed without line breaks.

- Add NormalizeKeyChar helper in internal/bidi/keys.go
- Apply conversion in both input.go (CLI) and router.go (WebSocket API)
- Add newline tests for JS async API and CLI
Rename NormalizeKeyChar to ConvertToKeyChar to better reflect its
purpose: mapping string literal characters (e.g. \n) to their
WebDriver BiDi keyboard equivalents (e.g. \uE006 Return key).
Also switch from \r to the canonical WebDriver Return key code.
@kevinsimler

Copy link
Copy Markdown
Contributor Author

I think you're right that \uE006 (or \uE007) is a better choice than \r. Since Vibium is converting the string passed into type() into keyDown/keyUp actions, we should use characters that map directly to keys whenever possible

Addressed in b2eeaae

@hugs hugs mentioned this pull request Aug 4, 2026
@hugs hugs closed this in #299 Aug 4, 2026
hugs pushed a commit that referenced this pull request Aug 4, 2026
A literal newline is not a key. WebDriver addresses Enter through the
normalized key value , so typing "123\n456" sent '\n' as a key value
the browser ignored and the textarea received "123456".

Original patch by Kevin Simler in #61. Rebased: the second call site moved
from internal/proxy/router.go to internal/api/handlers_interaction.go when
proxy was renamed to api (e61a1ed).
hugs added a commit that referenced this pull request Aug 4, 2026
The original tests drove https://seleniumbase.io/demo_page. Live external
sites stall and wedge the suite, so they now use the shared test server,
which gains a textarea fixture on /inputs.

Also covers element.type() in the JS client, which the CLI tests do not
reach, and updates CLICKER to VIBIUM after the binary rename (9bc9c17).
@hugs

hugs commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Landed in #299, with your commit intact. Thanks for the fix, and sorry it sat this long.

Your diagnosis was right and the patch needed no change. Only the surroundings had moved in the meantime: internal/proxy/router.go became internal/api/handlers_interaction.go, and CLICKER became VIBIUM after the binary rename.

The one thing I rewrote was the tests, which drove https://seleniumbase.io/demo_page. Live external sites stall and wedge our suite, so they now use the local test server. That rule is nowhere a contributor could find it, so it is on us, not you.

Worth noting your two-case split was well chosen. Against the unpatched binary the carriage-return case passes and the newline case fails, so one is a regression guard for behaviour that already worked and the other is the actual bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants