microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Bug]: I downloaded the microsoft playwright cli and it downloads the wrong versions of chrome #1690

Closed alethcoe closed 3 years ago

alethcoe commented 3 years ago

Playwright version

1.12.0

Operating system

Windows

What browsers are you seeing the problem on?

Chromium

Other information

On windows 10

What happened? / Describe the bug

trying running playwright install but when I would run playwright it could never find Chrome. If I blew away my cached browsers it would download them but the wrong versions.

If I rename the version of the folder it works but if I ever reinstall browsers I have to go do it again.

Code snippet to reproduce your bug

using System;
using Microsoft.Playwright;
using System.Threading.Tasks;

namespace PlaywrightDemo
{
    class Program
    {
    public static async Task Main()
    {
        using var playwright = await Playwright.CreateAsync();
        await using var browser = await playwright.Chromium.LaunchAsync();
        var page = await browser.NewPageAsync();
        await page.GotoAsync("https://playwright.dev/dotnet");
        await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png" });
    }
    }
}

Relevant log output

D:\Source\playwright_sharp\PlaywrightTests> playwright install
Removing unused browser at C:\Users\user\AppData\Local\ms-playwright\chromium-907428
Downloading Playwright build of chromium v888113 - 97.7 Mb [================] 100% 0.0s
Playwright build of chromium v888113 downloaded to C:\Users\aleth\AppData\Local\ms-playwright\chromium-888113

Unhandled exception. Microsoft.Playwright.PlaywrightException: Executable doesn't exist at C:\Users\user\AppData\Local\ms-playwright\chromium-907428\chrome-win\chrome.exe
╔═════════════════════════════════════════════════════════════════════════╗
║ Looks like Playwright Test or Playwright was just installed or updated. ║
║ Please run the following command to download new browsers:              ║
║                                                                         ║
║     npx playwright install                                              ║
║                                                                         ║
║ <3 Playwright Team                                                      ║
╚═════════════════════════════════════════════════════════════════════════╝
   at Microsoft.Playwright.Transport.Connection.SendMessageToServerAsync[T](String guid, String method, Object args)
   at Microsoft.Playwright.Core.BrowserType.LaunchAsync(BrowserTypeLaunchOptions options)
   at PlaywrightDemo.Program.Main() in D:\Source\playwright_sharp\PlaywrightDemo\Program.cs:line 12
   at PlaywrightDemo.Program.<Main>()
mxschmitt commented 3 years ago

This is caused by https://github.com/microsoft/playwright/issues/7741

executing playwright install without the npx should fix it.

alethcoe commented 3 years ago

I didn't run npx, you can see in the first line of my traces from my powershell i was running, playwright install without npx. This should have been using the playwright cli installed through dotnet tools. We are running into the same behavior in windows docker containers.

mxschmitt commented 3 years ago

Whats your output of Get-Command playwright in PowerShell? Seems like its using the wrong Playwright CLI.

alethcoe commented 3 years ago

Thank you for your help. Yes It was pointed at a previous python version of playwright.

I moved my environment variable up to put dotnet ahead of python and it works now. Closing as it was my error due to other language cli taking precedence.

rsantosdev commented 2 years ago

@mxschmitt I'm reopening this as I'm trying to upgrade to v1.17 and no matter what I do it doesn't download the correct chromium version.

My Tools installation image

I cleaned the ms-playwright folder and is still downloading the older version image

rsantosdev commented 2 years ago

My apologies, after reading this again carefully I remembered that I was upgrading from .net 5 to .net 6 and I forgot to clear previous builds if anyone has the same issue, just run this command from the repo root folder to clear all bin and obj folders:

Get-ChildItem .\ -include bin,obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }