Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Fix TypeError in codegen (#35921)

Rui Figueiracd32b0a2312e
diff --git a/packages/injected/src/recorder/recorder.ts b/packages/injected/src/recorder/recorder.ts
index 8aabd80a00..a7b5507f38 100644
--- a/packages/injected/src/recorder/recorder.ts
+++ b/packages/injected/src/recorder/recorder.ts
@@ -545,6 +545,10 @@ class RecordActionTool implements RecorderTool {
}
private _shouldGenerateKeyPressFor(event: KeyboardEvent): boolean {
+ // IME can generate keyboard events that don't provide a value for the key property (e.g. chrome autofill)
+ if (typeof event.key !== 'string')
+ return false;
+
// Enter aka. new line is handled in input event.
if (event.key === 'Enter' && (this._recorder.deepEventTarget(event).nodeName === 'TEXTAREA' || this._recorder.deepEventTarget(event).isContentEditable))
return false;