question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] browser.newContext: Unknown permission: clipboard-read for webkit

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dgozmancommented, Jul 14, 2022

We suggest to set permission per browser. Most likely, you already have test projects with different browsers configured, so just move permission to the respective project.

// playwright.config.ts

export default {
  projects: [
    {
      name: 'chromium',
      browserName: 'chromium',
      use: {
        contextOptions: {
          // chromium-specific permissions
          permissions: ['clipboard-read', 'clipboard-write'],
        },
      },
    },
    {
      name: 'firefox',
      browserName: 'firefox',
      use: {
        contextOptions: {
          // firefox-specific permissions
          permissions: ['geolocation'],
        },
      },
    },
  ],
};
1reaction
miraocommented, Apr 15, 2022

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-write if 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browser | Playwright - CukeTest
In a newly created browser, this will return zero browser contexts. const browser = await pw.webkit.
Read more >
BrowserContext (Playwright - Main Library 1.12.1 API)
Clears all permission overrides for the browser context. BrowserContext context = browser.newContext(); context.grantPermissions(Arrays.asList("clipboard-read")); ...
Read more >
mozilla-central: changeset 463200 ...
Find changesets by keywords (author, files, the commit message), revision number or hash, or revset expression. bug 1523104: remote: add browser mochitest to ......
Read more >
All the Electron Docs! | Electron
Electron is an open source library developed by GitHub for building cross-platform desktop applications with HTML, CSS, and JavaScript. Electron accomplishes ...
Read more >
Index - Web APIs
# Page Tags and summary 1 Web APIs. ⚠️ API, DOM, Landing, Reference, Web 2 ANGLE_instanced_arrays. ⚠️ API, Reference, WebGL, WebGL extension 13 AbortSignal: abort event....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found