Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playwright (.NET) tries to use different browser versions than installed

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?

like image 545
hubesal Avatar asked Dec 06 '25 04:12

hubesal


2 Answers

# 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.)

like image 179
Max Schmitt Avatar answered Dec 08 '25 17:12

Max Schmitt


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.

like image 41
hubesal Avatar answered Dec 08 '25 17:12

hubesal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!