Rayrun

How do I enable debug logging in Playwright and manage screen recordings?

Answer

Enable Debug Logging in Playwright

To enable debug logging in Playwright, run your tests with the --debug flag. This launches the Playwright inspector, allowing you to step through your test, view actionability logs, and edit locators live while seeing them highlighted in the browser window.

npx playwright test --debug

Alternatively, you can configure local debugging using the VS Code extension. Run tests in debug mode by right-clicking on the line next to the test you want to run. This opens a browser window and pauses at the breakpoint. You can then live debug your test by clicking or editing locators in your test in VS Code, which highlights the locator in the browser window and shows any other matching locators found on the page.

Manage Screen Recordings

Although verifying fake video input is not mentioned for version 1.35.1, you can manage screen recordings using Playwright's APIs like video.delete() and video.saveAs(). These APIs allow you to control the screen recording of your tests.

Here's an example of how to save a screen recording:

import { test, expect } from '@playwright/test';

test('Save screen recording', async ({ page }) => {
  await page.goto('https://ray.run/');
  const video = await page.video();
  await video.saveAs('recording.mp4');
});

And to delete a screen recording:

import { test, expect } from '@playwright/test';

test('Delete screen recording', async ({ page }) => {
  await page.goto('https://ray.run/');
  const video = await page.video();
  await video.delete();
});

By using these APIs, you can manage screen recordings effectively in your Playwright tests.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.