playwright-dotnet: [BUG] Only Video folder is getting create, video is not generating inside it

using log4net;
using Microsoft.Extensions.Configuration;
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlaywrightTests.Utils
{
    public class TestHooks: PageTest
    {
        public static readonly ILog log = LogManager.GetLogger(typeof(Tests));
      

        public override BrowserNewContextOptions ContextOptions()
        {
            return new BrowserNewContextOptions()
            {
                RecordVideoDir = "videos/webapp",
                ViewportSize = new ViewportSize
                {
                    Height = 720,
                    Width = 1280
                },
                RecordVideoSize = new RecordVideoSize
                {
                    Height = 720,
                    Width = 1280
                },
                ColorScheme = ColorScheme.Dark,
                BaseURL = "https://playwright.dev",
            };
        }

        [SetUp]
        public async Task Setup()
        {
            Console.WriteLine("log object " + log);
            // Specify the log4net configuration file
            log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));
            Console.WriteLine("log started----- ");
            log.Debug("Debug message");
            log.Info("Info message");
            log.Warn("Warning message");
            log.Error("Error message");
            log.Fatal("Fatal message");
            /*   await using var browser = await Page.Context.Browser.BrowserType.LaunchAsync();
                   Console.WriteLine("browser<<<<<"+browser.BrowserType.Name);
                   context = await browser.NewContextAsync();*/

            // Start tracing before creating / navigating a page.
           
             await Context.Tracing.StartAsync(new()
            {
                Screenshots = true,
                Snapshots = true,
                Sources = true
            });
           
            
            await Page.GotoAsync("https://playwright.dev");
        }

    }
}

in test file-

using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
using NUnit.Framework;
using PlaywrightTests.Pages.Actions;
using PlaywrightTests.Pages.Models;
using log4net;
using PlaywrightTests.Utils;

namespace PlaywrightTests;

[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class Tests : TestHooks
{
    

    [SetUp]
    public async Task Setups()
    {
        Console.WriteLine("log object " +log);
        Console.WriteLine("log started----- ");
        // Example log statements
        log.Debug("<<<<<<<<<<<<Debug message");
        log.Info("Info message");
        log.Warn("Warning message");
        log.Error("Error message");
        log.Fatal("Fatal message");

      
    }

    [Test]
    public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
    {
        // Example log statements
        log.Debug("!!!!!!!!!!!!!!!Debug message");
        log.Info("Info message");
        log.Warn("Warning message");
        log.Error("Error message");
        log.Fatal("Fatal message");
        // Expect a title "to contain" a substring.
        await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
        

        // create a locator
        var getStarted = Page.GetByRole(AriaRole.Link, new() { Name = "Get started" });

        // Expect an attribute "to be strictly equal" to the value.
        await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");

        // Click the get started link.
        await getStarted.ClickAsync();

        // Expects the URL to contain intro.
        await Expect(Page).ToHaveURLAsync(new Regex(".*intro"));
         Thread.Sleep(20000);
        
        // Stop tracing and export it into a zip archive.

        await Context.Tracing.StopAsync(new()
        {
            Path = "trace.zip"
        });
    }

 
     
  
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Awesome, that helped me to reproduce it. So the reason for that is that you are on Windows and specifying a path which is more linux like: "videos/webapp",. This gets combined incorrectly and Firefox does not know how to deal with it.

You should either do "videos\\webapp" since you are on windows or Path.Combine("videos", "webapp") to have it cross-platform or specify an absolute path, then it will work as expected.