All, I cannot get videos of my tests to record in VS Code. I have video set to "on" in my palywright.config.ts file:
export default defineConfig({ use: { trace: 'on-first-retry', video: 'on', },
I even tried creating my own context:
let page: Page; let context: BrowserContext;
test.beforeAll(async ({ browser }) => {
context = await browser.newContext({
recordVideo: {
dir: ./videos/
,
},
});
});
test.beforeEach(async () => { page = await context.newPage(); await login(page, config.user, config.pwd); });
No matter what I do, I never see video files. If I run the tests in the test runner or via command line, I do see video files show up. Any thoughts?
This thread is trying to answer question "Why can't the user get videos of their tests to record in VS Code despite having the correct settings?"
Related Ask AI answer for "What are some reasons why videos of tests might not record in VS Code using Playwright despite having the correct settings?".
If you're having trouble recording videos of your tests in VS Code with Playwright, there could be a few reasons why.
First, make sure your Playwright configuration is correctly set up. Videos are turned off by default, so you need to explicitly set the video
option to 'on'
, 'retain-on-failure'
, or 'on-first-retry'
.
import { test, expect } from '@playwright/test';
test('basic test', async ({ page }) => {
await page.goto('https://ray.run/');
// your test code here
});
Next, ensure that browser contexts are properly closed at the end of each test. Videos are saved upon browser context closure. If a browser context is not closed manually using browserContext.close()
, then videos may not be recorded or saved.
await browserContext.close();
The default video size is the viewport size scaled down to fit 800x800 pixels. If necessary, adjust your desired video size by setting specific width and height values in your Playwright config file.
If you're testing multiple pages simultaneously, close both individual pages and browser contexts before attempting access via page.video().path()
. Videos will only become available after either page or browser context closure.
Lastly, make sure all dependencies and versions of Playwright libraries are up-to-date. If you've checked all these settings and you're still having issues, it might be worth looking for any conflicting configurations or extensions within VS Code itself.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].