Skip to content

witcher-pro/playwright-dotnet

 
 

Repository files navigation

Playwright for .NET 🎭

NuGet version Join Discord

Linux macOS Windows
Chromium 138.0.7204.23
WebKit 18.5
Firefox 139.0

Playwright for .NET is the official language port of Playwright, the library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Documentation

https://playwright.dev/dotnet/docs/intro

API Reference

https://playwright.dev/dotnet/docs/api/class-playwright

Pull from the original repository

git fetch upstream main
git pull upstream main

Build and Publish

# 1. Update the version from `/playwright-dotnet/src/Common/Version.props` file
# 2. Delete the .drivers folder from `/playwright-dotnet/src/Playwright/.drivers`
# 3. Go to the root folder of the repo. And run the dotnet command to download the drivers again.
cd playwright-dotnet
dotnet run --project ./src/tools/Playwright.Tooling/Playwright.Tooling.csproj -- download-drivers --basepath .

# 4. Go to src and run build
cd src
dotnet build

# 5. Now publish a release for nuget.
dotnet pack -c Release
# dotnet pack -c Release /p:ApiCompatGenerateSuppressionFile=true

# 6. Push to Nuget registry
dotnet nuget push .\Playwright\bin\Release\WitcherPro.Playwright.<version>.nupkg -k <api-key-here> -s https://api.nuget.org/v3/index.json

Build and Publish to Docker registry

Make sure to log-in to your Docker account first.

cd ./utils/docker
.\publish_docker.ps1 -ReleaseChannel "stable" -DockerHubUsername "your_username"
# .\publish_docker.ps1 -ReleaseChannel "stable" -DockerHubUsername "kaljfeakjldghasioeg"
using System.Threading.Tasks;
using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new() { Headless = false });
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await page.ScreenshotAsync(new() { Path = "screenshot.png" });

Other languages

More comfortable in another programming language? Playwright is also available in

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Languages

  • C# 51.2%
  • JavaScript 47.1%
  • TypeScript 0.8%
  • HTML 0.7%
  • PowerShell 0.1%
  • Shell 0.1%