Issue 1:
System info

Playwright Version: 1.35.1

Operating System: Debian Docker

Browser: Chromium

Other info:

Source code

I provided exact source code that allows reproducing the issue locally.

I've been running test suites with Playwright in our company for almost a year, and have had no real issues. However, when we tried to onboard one of our larger components to use it, we sometimes get this error:

...
Error: browserContext.addCookies: Browser closed.
==================== Browser output: ====================
<launching> /browsers/chromium-1067/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-06Snae --remote-debugging-pipe --no-startup-window
<launched> pid=178
[pid=178][err] [0712/10[52](https://gitlab.company/-/jobs/1)35.920816:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[pid=178][err] [0712/105236.019824:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[pid=178][err] [0712/105236.020034:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[pid=178][err] [0712/105236.034717:ERROR:zygote_host_impl_linux.cc(273)] Failed to adjust OOM score of renderer with pid 198: Permission denied (13)
[pid=178][err] [0712/105236.0352[56](https://gitlab.ballys.tech/dumarca/webfront/-/jobs/6638467#L56):WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.
[pid=178][err] [0712/105236.083639:ERROR:zygote_host_impl_linux.cc(273)] Failed to adjust OOM score of renderer with pid 206: Permission denied (13)
[pid=178][err] [0712/105236.104770:WARNING:sandbox_linux.cc(393)] InitializeSandbox() called with multiple threads in process gpu-process.
[pid=178][err] [0712/105236.118682:ERROR:command_buffer_proxy_impl.cc(128)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
[pid=178] <gracefully close start>
Failed worker ran 1 test:
[project] › tests/search/search.spec.ts:3:5 › Search bar is visible on home page @rdge @plng @se @afun
at Player.setDismissCookieNotification (/opt/test-root/node_modules/@ci-cd/player/src/pageObjects/player.po.js:47:29)
at Player.<anonymous> (/opt/test-root/node_modules/@ci-cd/player/src/pageObjects/player.po.js:72:18)
at fulfilled (/opt/test-root/node_modules/@ci-cd/player/src/pageObjects/player.po.js:5:[58](https://gitlab.company/jobs/1))
··
3 passed (20.7s)
1 error was not a part of any test, see above for details
...

This happens rarely, about one in every thirty runs, and the test themselves are completely empty, only doing a call to an endpoint to make sure we can track the test is run. What might be the cause of this issue? There really isn't anything to share in terms of code, I scaled down to run basically an empty project, and the rest is proven to work, having ran thousands and thousands of suites over a year with no problems. What kind of interaction might cause these problems so I know where to start to look?

Expected

The test runs and passes successfully.

Actual

The test runs and passes, but the overall suite fails with the above mentioned error.

Issue 2:
System info

Playwright Version: [v1.31.2]

Operating System: [Windows 10]

Browser: [Chromium]

Other info:

I am trying to launch for every test of my repo the same persistent context that I got in my userDir folder.. unfortunately as I have read in other issues, launching a persistent context does force you to reconfigure your test options to make everything work well..

With that said..I am having some issue with saving the videos of every test in my reporter folder. I have a playwright HTML report and an Allure-playwright report. For both of them the video would not showing up, even if I managed to save them in the proper output directory. Below the code of how I set the context:

Source code

let context: BrowserContext;
let page: Page;
signinUrl = baseURL;
console.log(testInfo.outputDir);
context = await playwright[browserName].launchPersistentContext('C:/Users/admin/Desktop/TEST_REPO/userDir', {
baseURL: signinUrl,
viewport: {
"width": 1366,
"height": 670
}, recordVideo: {
dir: testInfo.outputDir,
size: {
width: 1280,
height: 625
}
},
locale: "it-IT",
proxy: {
server: "IP:port",
bypass: "some.domain"
},
timezoneId: "Europe/Rome",
});
page = context.pages()[0];

Config file

This is the config style tha I would normally have without using a persistent context and that indeed works pretty well (video, screenshots, ecc...)

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
projects: [
{
name: 'chromium',
"reporter": [
[
"line"
],
[
"allure-playwright"
],
[
"html",
{
"outputFolder": "playwright-report",
"open": "never"
}
]
],
"use": {
"locale": "it-IT",
"launchOptions": {
"proxy": {
"server": "IP:port",
"bypass": "some.domain"
}
},
"contextOptions": {
"locale": "it-IT",
"timezoneId": "Europe/Rome"
},
"viewport": {
"width": 1366,
"height": 670
},
"screenshot": "only-on-failure",
"video": {
"mode": "on",
"size": {
"width": 1280,
"height": 625
}
},
"trace": "retain-on-failure"
}
}
});

Steps

Run the test

the test can fail or pass

Expected

Expect to have my recorded videos inside the HTML and Allure report.

Actual

That does not happen.

I want also to add that the screenshots insted do appear in my report even if in my persistent context I do not specify anything about while it is specified inside my config.

Also, how can I specify inside my persisten context wheneve I want to record a video? Something like "Only on failure" ecc... thank you.