Skip to content

Using document from getDocument in a query causes a TypeError #478

@flakey-bit

Description

@flakey-bit

The snapshotter in Playwright attempts to call setAttribute on the element it is passed.

This causes a TypeError (setAttribute is not a function) because no such function exists on document

image

image

To reproduce:

const $document = await getDocument(page);
await getByRole($document, "heading", { level: 2, name: "Prepare file for upload"});

Workaround:

await page.mainFrame().evaluate(() => {
    Object.defineProperty(document, "setAttribute", { value: () => {}});
  });

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleased🎭 compatabilityPlaywright compatability issue or upstream API change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions