Skip to content

docs: warn that press_key/fill_input double-inserts characters on newer Chrome#419

Open
blaircullen wants to merge 1 commit into
browser-use:mainfrom
blaircullen:fix/press-key-double-insert
Open

docs: warn that press_key/fill_input double-inserts characters on newer Chrome#419
blaircullen wants to merge 1 commit into
browser-use:mainfrom
blaircullen:fix/press-key-double-insert

Conversation

@blaircullen

Copy link
Copy Markdown

What

Adds a field-tested gotcha to SKILL.md: press_key (and therefore fill_input, which calls it per character) double-inserts every character on newer Chrome.

Repro

new_tab("about:blank")
js("document.body.innerHTML='<input id=t>';document.querySelector('#t').focus();")
for ch in "abc": press_key(ch)
js("(()=>document.querySelector('#t').value)()")   # -> "aabbcc"   (expected "abc")

Confirmed on HeadlessChrome 149.0.0.0. Real-world symptom: a login filled via fill_input sent mm33mmeeddiiaa for m3media and the site returned "Invalid username or password" — looked like a credential problem, was actually doubled input.

Root cause

press_key dispatches keyDown with a text field and a separate char event:

cdp("Input.dispatchKeyEvent", type="keyDown", **base, **({"text": text} if text else {}))
if text and len(text) == 1:
    cdp("Input.dispatchKeyEvent", type="char", text=text, ...)

On newer Chrome the keyDown carrying text already inserts the character, so the explicit char event inserts it a second time. (On older builds keyDown(text) apparently didn't auto-insert, so the pair produced a single insert — hence it worked before.)

This PR

Documentation only — adds the symptom, root cause, and a native-value-setter workaround for controlled inputs.

Suggested real fix (not in this PR)

Make press_key insert exactly once on all Chrome versions — either drop text from the keyDown and let the char event do the insert, or send rawKeyDown + char. Happy to follow up with the code change + a regression test if you'd prefer it in the same PR.

🤖 Generated with Claude Code

…er Chrome

press_key dispatches keyDown WITH a `text` field AND a separate `char` event.
On newer Chrome (confirmed HeadlessChrome 149) the keyDown(text) already inserts
the character, so the char event duplicates it — typing "abc" yields "aabbcc"
(e.g. m3media -> mm33mmeeddiiaa), which often surfaces as a bogus
"invalid username/password" on login forms.

Documents the symptom, root cause, a native-value-setter workaround for
controlled inputs, and the real fix (drop `text` from the keyDown, or use
rawKeyDown+char) in the field-tested gotchas.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@browser-harness-review

Copy link
Copy Markdown

✅ Skill review passed

Reviewed 1 file(s) — no findings.

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.

1 participant