Skip to content

Commit e5b3e6f

Browse files
committed
fix: use ElementHandle to document.body instead of document
Using `document` was causing a runtime error in the page as Playwright's snapshot internals expect a proper element that can be "marked" via `Element.setAttribute`. See: https://github.com/microsoft/playwright/blob/20957f820d34a53003ab0722fa149c80fedec846/packages/playwright-core/src/server/trace/recorder/snapshotter.ts#L107-L109 See: #478 Fixes #478
1 parent 93f3d1c commit e5b3e6f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ function createDelegateFor<T = DOMReturnType>(
157157
export async function getDocument(_page?: Page): Promise<ElementHandle> {
158158
// @ts-ignore
159159
const page: Page = _page || this
160-
const documentHandle = await page.mainFrame().evaluateHandle('document')
160+
const documentHandle = await page.mainFrame().evaluateHandle<HTMLElement>('document.body')
161161
const document = documentHandle.asElement()
162+
162163
if (!document) throw new Error('Could not find document')
164+
163165
return document
164166
}
165167

0 commit comments

Comments
 (0)