Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(dotnet): Playwright examples (#6558)

Anže Vodovnikea59fd8f83ed
diff --git a/docs/src/api/class-playwright.md b/docs/src/api/class-playwright.md
index ec978847a8..2533ddf910 100644
--- a/docs/src/api/class-playwright.md
+++ b/docs/src/api/class-playwright.md
@@ -65,6 +65,24 @@ with sync_playwright() as playwright:
run(playwright)
```
+```csharp
+using Microsoft.Playwright;
+using System.Threading.Tasks;
+
+class PlaywrightExample
+{
+ public static async Task Main()
+ {
+ using var playwright = await Playwright.CreateAsync();
+ await using var browser = await playwright.Chromium.LaunchAsync();
+ var page = await browser.NewPageAsync();
+
+ await page.GoToAsync("https://www.microsoft.com");
+ // other actions...
+ }
+}
+```
+
## property: Playwright.chromium
- type: <[BrowserType]>
@@ -135,6 +153,25 @@ with sync_playwright() as playwright:
Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
+```csharp
+using Microsoft.Playwright;
+using System.Threading.Tasks;
+
+class PlaywrightExample
+{
+ public static async Task Main()
+ {
+ using var playwright = await Playwright.CreateAsync();
+ await using var browser = await playwright.Webkit.LaunchAsync();
+ await using var context = await browser.NewContextAsync(Playwright.Devices["iPhone 6"]);
+
+ var page = await context.NewPageAsync();
+ await page.GoToAsync("https://www.theverge.com");
+ // other actions...
+ }
+}
+```
+
## property: Playwright.errors
* langs: js
- type: <[Object]>