microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.41k stars 3.63k forks source link

[Question] Video recording not storing file in root with .Net #11890

Closed davidhprotective closed 2 years ago

davidhprotective commented 2 years ago

-Windows 10 -Playwright version 1.18 -Using with .Net

In order to see how video recording feature works, I set up a sample test class like below but somehow cannot get video file generated. I am probably missing something very basic. Can someone please assist?

using System;
using AcceptanceTests.Common;
using Microsoft.Playwright;
using Xunit;

namespace AcceptanceTests
{
    public class SampleTests : IDisposable
    {
        private readonly IPlaywright _playwright;
        private readonly IBrowser _browser;
        private readonly IPage _page;
        private readonly IBrowserContext _context;

        public SampleTests()
        {
            var config = new TestConfiguration();

            _playwright = Playwright.CreateAsync().Result;
            _browser = _playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
            {
                Headless = config.RunHeadless,
                Args = new[] { "--disable-dev-shm-usage" }
            }).Result;
            _context = _browser.NewContextAsync(new BrowserNewContextOptions
            {
                RecordVideoDir = "videos/",
                RecordVideoSize = new RecordVideoSize() { Width = 640, Height = 480 }
            }).Result;

            _page = _context.NewPageAsync().Result;
        }

        [Fact]
        public void VerifyTitle()
        {
            _page.GotoAsync("https://playwright.dev/dotnet/docs/videos").Wait();
            Assert.True(_page.TitleAsync().Result.Contains("Videos"));
        }

        public void Dispose()
        {
            _context?.CloseAsync().Wait();
            _browser.CloseAsync().Wait();
            _playwright.Dispose();
        }
    }
}
davidhprotective commented 2 years ago

I just found that videos were being generated under bin/Debug/net5.0/videos/ and I am wondering why it is not placing it in project root directory.

davidhprotective commented 2 years ago

Also, two additional questions for video recording feature:

  1. Is it meant to be used with headless mode only? My tests fail when I run it video recording ON in headed mode.
  2. Video resolution is extremely low. Is there any way to improve it slightly?
pavelfeldman commented 2 years ago

Overall, we discourage using videos in favor or our tracing features. They are much more comprehensive an performant. See https://playwright.dev/dotnet/docs/trace-viewer.

pavelfeldman commented 2 years ago

Closing as per above. Please file a new issue and link this one if there are outstanding issues!