From 97b975b5ec8f79a42abefd09a29dc4669ac70752 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 26 Jan 2022 20:43:44 +0100 Subject: [PATCH] docs(dotnet): add API to run CLI commands (#11641) --- docs/src/intro-csharp.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/src/intro-csharp.md b/docs/src/intro-csharp.md index 4544e248cf..b8f4542716 100644 --- a/docs/src/intro-csharp.md +++ b/docs/src/intro-csharp.md @@ -122,6 +122,18 @@ dotnet test -- NUnit.NumberOfTestWorkers=5 pwsh bin\Debug\netX\playwright.ps1 codegen ``` +## Install browsers via API + +It's possible to run [Command line tools](./cli.md) commands via the .NET API: + +```csharp +var exitCode = Microsoft.Playwright.Program.Main(new[] {"install"}); +if (exitCode != 0) +{ + throw new Exception($"Playwright exited with code {exitCode}"); +} +``` + ## System requirements The browser binaries for Chromium, Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):