fix: use correct VK codes for punctuation in type command (#836)
* fix: use correct Windows virtual-key codes for punctuation in type command The `type` command was dropping punctuation characters like `.`, `'`, and `#` because `char_to_key_info()` used raw ASCII codes as the `windowsVirtualKeyCode` in CDP `Input.dispatchKeyEvent` calls. For punctuation the ASCII value collides with unrelated VK codes — most critically '.' (ASCII 46) equals VK_DELETE (0x2E), causing Chrome to interpret periods as Delete key presses. Changes: - Add `punctuation_key_info()` with correct VK_OEM_* codes matching Playwright's USKeyboardLayout (e.g. Period=190, Slash=191, Semicolon=186) - Fall back to `Input.insertText` for characters without a US keyboard mapping (emoji, CJK, etc.), matching Playwright's `keyboard.type()` - Update e2e test to use `type` instead of `fill` workaround for email - Add unit tests verifying VK code parity with Playwright's layout Fixes #833 * style: fix rustfmt formatting for InsertTextParams --------- Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -406,9 +406,9 @@ async fn e2e_form_interaction() {
|
||||
assert_success(&resp);
|
||||
assert_eq!(get_data(&resp)["result"], "John Doe");
|
||||
|
||||
// Fill email (use fill instead of type to avoid key dispatch issues with '.')
|
||||
// Type email – the type action now correctly handles punctuation like '.'
|
||||
let resp = execute_command(
|
||||
&json!({ "id": "12", "action": "fill", "selector": "#email", "value": "john@example.com" }),
|
||||
&json!({ "id": "12", "action": "type", "selector": "#email", "text": "john@example.com" }),
|
||||
&mut state,
|
||||
)
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user