Installation Steps#
Warning
Although the installation process is universal, this article is mainly for Windows users.
Perform the following steps in the target project where you want to install Playwright
:
- Install Playwright dependencies for the specified project:
dotnet add package Microsoft.Playwright
- Build the project, which will generate the playwright.ps1 file in the bin directory (used for downloading headless browsers Chromium, WebKit, and Firefox, and some other dependencies):
dotnet build
- Install or update the PowerShell global command
pwsh
:
If it doesn't exist, it will be automatically installed during update
dotnet tool update --global PowerShell
- Replace
netX
with the actual output folder name to execute the script file in the bin directory for installing the required browsers, such asnet7.0
:
pwsh bin/Debug/netX/playwright.ps1 install
If you encounter the following error during install
, it is because the .NET Core type does not copy the NuGet package DLLs to the debug directory. Refer to: https://github.com/microsoft/playwright-dotnet/issues/2127#issuecomment-1148565925
Therefore, you need to execute install
in the console or web project that references the libraries, as that is where the Microsoft.Playwright.dll
and other files will be present. It should be executed as shown in the screenshot below:
After execution, three different browser engines will be downloaded:
Installation Directory#
After the installation is complete, you can find the headless browsers (Windows) in the following directory:
%USERPROFILE%\AppData\Local\ms-playwright