Closed marcusNumminen closed 5 months ago
In order to use clipboard, you need to give it clipboard permissions like that:
test.use({
permissions: ['clipboard-write']
})
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
await page.evaluate('navigator.clipboard.writeText("XXXYYYZZZXXXYYYZZZ")');
});
in headed/headless the concept of permissions is implement different on Chromium since, hence its working. So far there's no good clipboard support in browsers for automation. Even the clipboard that works in headful version of browsers is not well isolated from the OS, so other things can interfere with running tests.
There's a request for better clipboard isolation: https://github.com/microsoft/playwright/issues/13097
I'll close this in favor of that request.
Version
1.41.2
Steps to reproduce
Run this test both headed and headless;
In
headed mode
this works fine but inheadless mode
I get the error:Error: page.evaluate: DOMException: Write permission denied.
Expected behavior
I expect the same behavior in headed and headless mode
Actual behavior
I get different behavior in headed and headless mode
Additional context
No response
Environment