Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
doc: fix first .net script (#6922)
Pavel Feldman4b5ad33cf833
diff --git a/docs/src/intro-csharp.md b/docs/src/intro-csharp.mdindex bbcd86c4fd..815da347e2 100644--- a/docs/src/intro-csharp.md+++ b/docs/src/intro-csharp.md@@ -19,43 +19,34 @@ dotnet tool install --global Microsoft.Playwright.CLICreate a console project and add the Playwright dependency.```bash+# Create projectdotnet new console -n pw_democd pw_demo-dotnet add package Microsoft.Playwright --prerelease-```-Ensure browsers necessary for testing are installed.+# Install dependencies+dotnet add package Microsoft.Playwright --prerelease-```bash-playwright install+# Install local Playwright tool and use it to install browsers.+dotnet new tool-manifest+dotnet tool install Microsoft.Playwright.CLI --version 1.0.0-alpha-1+dotnet playwright install```Create a `Program.cs` that will navigate to `https://playwright.dev/dotnet` and take a screenshot in Chromium.```csharp-using System;+using Microsoft.Playwright;using System.Threading.Tasks;-using Microsoft.Playwright.NUnit;-using NUnit.Framework;-namespace PlaywrightTests+class Program{- [Parallelizable(ParallelScope.Self)]- public class MyTest : PageTest+ public static async Task Main(){- [Test]- public async Task ShouldAdd()- {- int result = await Page.EvaluateAsync<int>("() => 7 + 3");- Assert.AreEqual(10, result);- }-- [Test]- public async Task ShouldMultiply()- {- int result = await Page.EvaluateAsync<int>("() => 7 * 3");- Assert.AreEqual(21, result);- }+ 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" });}}```@@ -77,30 +68,38 @@ await playwright.Firefox.LaunchAsync(new BrowserTypeLaunchOptions { Headless = fYou can choose to use NUnit test fixtures that come bundled with Playwright. These fixtures support running tests on multiple browser engines in parallel, out of the box. Learn more about [Playwright with NUnit](./test-runners.md).```bash-dotnet new console -n pw_test+# Create new project.+dotnet new nunit -n PlaywrightTestscd pw_test++# Install dependenciesdotnet add package Microsoft.Playwright --prereleasedotnet add package Microsoft.Playwright.NUnit --prerelease-```-Ensure browsers necessary for testing are installed.--```bash-playwright install+# Install local Playwright tool and use it to install browsers.+dotnet new tool-manifest+dotnet tool install Microsoft.Playwright.CLI --version 1.0.0-alpha-1+dotnet playwright install```-Create a PageTests.cs file.+Edit UnitTest1.cs file.```csharp-using System;using System.Threading.Tasks;using Microsoft.Playwright.NUnit;using NUnit.Framework;-namespace ExampleTest+namespace PlaywrightTests{[Parallelizable(ParallelScope.Self)]- public class PageTests : PageTest+ public class Tests : PageTest{+ [Test]+ public async Task ShouldAdd()+ {+ int result = await Page.EvaluateAsync<int>("() => 7 + 3");+ Assert.AreEqual(10, result);+ }+[Test]public async Task ShouldMultiply(){@@ -112,7 +111,6 @@ namespace ExampleTest``````bash-dotnet builddotnet test -- NUnit.NumberOfTestWorkers=5```diff --git a/docs/src/test-runners-csharp.md b/docs/src/test-runners-csharp.mdindex 2b8499d71a..9fa343e2c6 100644--- a/docs/src/test-runners-csharp.md+++ b/docs/src/test-runners-csharp.md@@ -59,7 +59,6 @@ namespace PlaywrightTestsRun your tests against Chromium```bash-dotnet builddotnet test```