Open
Description
Version
1.48.2
Steps to reproduce
Local: MacOS
CI Runner: Docker Linux
- Run a test with webkit
- Open a new page on the same website.
- Try to read clipboard
config:
import { defineConfig, devices } from '@playwright/test';
import 'dotenv/config';
import path from 'path';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
require('dotenv').config({ path: path.resolve(__dirname, 'e2e', '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e/tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
locale: 'en-us',
},
/* Configure projects for major browsers */
projects: [
{ name: 'setup', testMatch: /.*\.setup\.ts/ },
{
name: 'chromium',
testMatch: /.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
storageState: '.auth/user.json',
contextOptions: {
permissions: ['clipboard-read', 'clipboard-write'],
},
},
dependencies: ['setup'],
},
{
name: 'firefox',
testMatch: /.*\.spec\.ts/,
use: {
...devices['Desktop Firefox'],
storageState: '.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'webkit',
testMatch: /.*\.spec\.ts/,
use: {
...devices['Desktop Safari'],
storageState: '.auth/user.json',
contextOptions: {
permissions: ['clipboard-read'],
},
},
dependencies: ['setup'],
},
{
name: 'smoke-chromium',
testMatch: /.*\.smoke\.ts/,
use: {
...devices['Desktop Chrome'],
storageState: '.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'smoke-firefox',
testMatch: /.*\.smoke\.ts/,
use: {
...devices['Desktop Firefox'],
storageState: '.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'smoke-webkit',
testMatch: /.*\.smoke\.ts/,
use: {
...devices['Desktop Safari'],
storageState: '.auth/user.json',
},
dependencies: ['setup'],
},
});
code:
const page2 = await context.newPage();
await page2.goto(LINK_ON_THE_SAME_PAGE);
const clipboardContent = await page2.evaluate(() => navigator.clipboard.readText());
running local:
npx playwright install --with-deps
npx playwright test --project=webkit
running ci:
npx playwright install --with-deps
npx playwright test --project=webkit
Expected behavior
The tests behave the same for local and ci.
Actual behavior
Local: works as expected
CI: Throws error: Error: page.evaluate: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
Additional context
No response
Environment
Local System:
OS: macOS 14.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 13.47 MB / 16.00 GB
Binaries:
Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
pnpm: 9.12.0 - ~/.nvm/versions/node/v18.18.2/bin/pnpm
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.48.2 => 1.48.2
CI Runner: Linux