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

getting started instructions dont work #1865

Closed SimonCropp closed 2 years ago

SimonCropp commented 2 years ago

Playwright version

1.17.2

Operating system

Windows

What browsers are you seeing the problem on?

Chromium

Other information

net6

What happened? / Describe the bug

following the getting started failes to install run the install script https://playwright.dev/dotnet/docs/intro/

Code snippet to reproduce your bug

PS C:\Code\New folder> dotnet new console -n PlaywrightDemo
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj...
  Determining projects to restore...
  Restored C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj (in 133 ms).
Restore succeeded.

PS C:\Code\New folder> cd .\PlaywrightDemo\
PS C:\Code\New folder\PlaywrightDemo> dotnet add package Microsoft.Playwright
  Determining projects to restore...
  Writing C:\Users\simon\AppData\Local\Temp\tmp3A63.tmp
info : Adding PackageReference for package 'Microsoft.Playwright' into project 'C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj'.
info :   CACHE https://api.nuget.org/v3/registration5-gz-semver2/microsoft.playwright/index.json
info : Restoring packages for C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj...
info : Package 'Microsoft.Playwright' is compatible with all the specified frameworks in project 'C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj'.
info : PackageReference for package 'Microsoft.Playwright' version '1.17.2' added to file 'C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj'.
info : Committing restore...
info : Generating MSBuild file C:\Code\New folder\PlaywrightDemo\obj\PlaywrightDemo.csproj.nuget.g.targets.
info : Writing assets file to disk. Path: C:\Code\New folder\PlaywrightDemo\obj\project.assets.json
log  : Restored C:\Code\New folder\PlaywrightDemo\PlaywrightDemo.csproj (in 176 ms).
PS C:\Code\New folder\PlaywrightDemo> dotnet build
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  PlaywrightDemo -> C:\Code\New folder\PlaywrightDemo\bin\Debug\net6.0\PlaywrightDemo.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.62
PS C:\Code\New folder\PlaywrightDemo> bin\Debug\net6.0\playwright.ps1 install
Unable to find type [Microsoft.Playwright.Program].
At C:\Code\New folder\PlaywrightDemo\bin\Debug\net6.0\playwright.ps1:4 char:1
+ [Microsoft.Playwright.Program]::Main($args)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Playwright.Program:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

PS C:\Code\New folder\PlaywrightDemo>

Relevant log output

No response

pavelfeldman commented 2 years ago

It looks like you need to do

pwsh bin\Debug\net6.0\playwright.ps1 install

I'll investigate why this is necessary.

pavelfeldman commented 2 years ago

https://stackoverflow.com/questions/42837447/powershell-unable-to-find-type-when-using-ps-5-classes

RiadKatby commented 2 years ago

I have the same problem, any update here in?

mxschmitt commented 2 years ago

@RiadKatby which OS/version/PowerShell/.NET version are you using? It would help us to debug this issue further.

BrandonQA commented 2 years ago

I ran "dotnet tool install --global PowerShell" before running "C:\Code\New folder\PlaywrightDemo> bin\Debug\net6.0\playwright.ps1 install" and my issues are resolved

dariusz-wozniak commented 2 years ago

In addition to @BrandonQA's answer:

dotnet tool update --global PowerShell

👆 Helped in my case

andrecustodio commented 2 years ago

I had the same issue that OP had. I followed the install and update commands that @BrandonQA and @dariusz-wozniak sent over, but didn't fix it. I was able to get it working after installing PowerShell Core from the MS website (Latest version in the time of this reply): https://docs.microsoft.com/pt-br/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2 Cheers!

Vunpac commented 2 years ago

If you don't want to install the extra PowerShell controls (I did this on my laptop and didn't want to do it on my desktop) you can get away with just installing the playwright CLI

"dotnet tool install --global Microsoft.Playwright.CLI"

then you can install the browsers with that using

"playwright install"

SimonCropp commented 2 years ago

i went with calling this in a ModuleInitializer

Microsoft.Playwright.Program.Main(new[] {"install"});
samayo commented 10 months ago

Eh, still the same issue. When will we ever get something that works outside the box

image

mxschmitt commented 10 months ago

Eh, still the same issue. When will we ever get something that works outside the box

image

It needs to be normal slashes instead of backslashes. Please create a new issue instead of reactivating old ones.

samayo commented 10 months ago

It can't be a normal slashes this is windows in powershell and these are standard slashes even the auto complete suggests it

peteroni commented 3 months ago

dotnet tool update --global PowerShell

The above Worked well for me. Thanks