Skip to content

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

fix(codegen): document.documentElement is null on early navigation (#33627)

Max Schmittc81504c5d6cd
diff --git a/packages/playwright-core/src/server/injected/highlight.ts b/packages/playwright-core/src/server/injected/highlight.ts
index c06e58f529..5720ffc539 100644
--- a/packages/playwright-core/src/server/injected/highlight.ts
+++ b/packages/playwright-core/src/server/injected/highlight.ts
@@ -90,7 +90,8 @@ export class Highlight {
}
install() {
- if (!this._injectedScript.document.documentElement.contains(this._glassPaneElement))
+ // NOTE: document.documentElement can be null: https://github.com/microsoft/TypeScript/issues/50078
+ if (this._injectedScript.document.documentElement && !this._injectedScript.document.documentElement.contains(this._glassPaneElement))
this._injectedScript.document.documentElement.appendChild(this._glassPaneElement);
}