playwright: [BUG] browser.newContext: Unknown permission: clipboard-read for webkit
Context:
- Playwright Version: 1.20.1
- Operating System: Mac
- Node.js version: 14.6
- Browser: webkit
Code Snippet
const config: PlaywrightTestConfig = {
globalTeardown: require.resolve('../src/utils/teardown'),
workers: configList.workers,
use: {
contextOptions: {
userAgent: configList.userAgent,
permissions: ['clipboard-read', 'clipboard-write']
},
test('test', async ({ browserName, page }) => {
expect(await page.screenshot({ fullPage: true, timeout: 4000 })).toMatchSnapshot(`${browserName}-EN.png`);
});
Describe the bug
Test is failing for webkit browser, if config file contains permissions: ['clipboard-read', 'clipboard-write'] however there is not any clipboard event is being used in this test
error :
3) [Desktop Firefox] › search/.test.ts:38:5 › Landing page Test Suite › test
browser.newContext: Unknown permission: clipboard-read
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 10
- Comments: 27 (2 by maintainers)
Commits related to this issue
- feat(profile): actually test clipboard copy Use a mock clipboard in order to determine if the copy button actually copies text into the clipboard. Thank you to krachtstefan for their mockClipboardAP... — committed to yalesites-org/yalesites-automated-tests by dblanken-yale 4 months ago
- ci: fix download e2e tests (#561) Fixes the download E2E tests by making the following changes: - Fix typos in workflow file that allows us to shard by browser - Add clipboard permissions in play... — committed to chanzuckerberg/cryoet-data-portal by codemonkey800 4 months ago
- YSP-315: E2E Testing V2 (#3) * feat(playwright): specify YALESITES_URL override * fix(search): search acknowledges there are breads The original test that tested against no mention of the word ... — committed to yalesites-org/yalesites-automated-tests by dblanken-yale 4 months ago
We suggest to set permission per browser. Most likely, you already have test projects with different browsers configured, so just move
permissionto the respective project.This approach should work
im also facing the same issue.
any update on this issue?? i’m facing it on webkit and firefox ? @dgozman @mxschmitt
This worked for me, except in Safari. If anyone can give me a hint on how to setup the proper permissions for safari, I would be very happy.
In the meantime I solved it by mocking the clipborad API and find it might be worth sharing:
e2e/utils/index.ts
e2e/mytest.ts
I had the same issue in Firefox, CodeceptJS + Playwright. In Firefox no permission is needed to have working “copy of text to clipboard” (note it works in secure sites only).
It would be great if Playwright was able to suppress the error
browser.newContext: Unknown permission: clipboard-writeif given browser doesn’t provide that feature. Currently I must allow such setting in test for Chromium and not for Firefox which makes tests more complex.@dgozman Could it be enhanced, so that if its included in the config file it will has no effect on webkit rather than make it fail, as the same config ia running agaisnt chrome and firefox in the same instance as well
Workaround for Firefox: