#navigator.clipboard permission in e2e

1 messages · Page 1 of 1 (latest)

terse cloak
#

Hiya folks! Long-time listener, first-time caller!

I'm working on a small component that copies text to the clipboard when clicked. All is going well, but while working on e2e testing I can't seem to set the permissions properly to access the navigator.clipboard.readText().

Example:

it('copies value to clipboard when clicked', async () => {

    const page = await newE2EPage();
    await page.setContent('<copybtn value="Copy me"></copybtn>');

    const button = await page.find('button');

    await button.click();

    expect(await page.evaluate(() => navigator.clipboard.readText())).toEqual("Copy me");
  });

Results in something like:

Evaluation failed: DOMException: Read permission denied.

Does anyone have ideas or suggestions? Thanks in advance!

lethal flare
terse cloak
#

@lethal flare thanks so much for the link. I'll check that out!