2

I have created some tests using Playwright with .NET bindings.

        [OneTimeSetUp]
    public async Task OneTimeSetUp()
    {
        random = new Random();
        var playwright = await Playwright.CreateAsync();
        browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
        {
            Headless = false
        });

        context = await browser.NewContextAsync();
        page = await context.NewPageAsync();
    }

Before running tests I had run

npx playwright install

before running tests. The outcome of aforementioned command are browsers installed in path C:\Users\username\AppData\Local\ms-playwright

enter image description here

When running tests however, error is thrown:

OneTimeSetUp: Microsoft.Playwright.PlaywrightException : Executable doesn't exist at C:\Users\11033414\AppData\Local\ms-playwright\chromium-907428\chrome-win\chrome.exe

so it seems like playwright wants to use other versions of browsers than installed ones. How to make Playwright point to correct versions of browsers installed?

hubesal
  • 141
  • 3
  • 13

2 Answers2

2
# Install the CLI once.
dotnet tool install --global Microsoft.Playwright.CLI
# Install the browsers
playwright install

(The current error description is a bug in 1.14, it gets fixed with 1.15.)

Max Schmitt
  • 2,529
  • 1
  • 12
  • 26
1

According to: https://github.com/microsoft/playwright-dotnet/issues/1638#issuecomment-887340857 the workaround is to use dotnet .\bin\Debug\net5.0\Microsoft.Playwright.dll -- install.

I've tried this and it works for me.

ouflak
  • 2,458
  • 10
  • 44
  • 49
hubesal
  • 141
  • 3
  • 13