diff --git a/docs/src/api/class-browser.md b/docs/src/api/class-browser.md index f9220fde66..281f01ee42 100644 --- a/docs/src/api/class-browser.md +++ b/docs/src/api/class-browser.md @@ -61,6 +61,24 @@ with sync_playwright() as playwright: run(playwright) ``` +```csharp +using Microsoft.Playwright; +using System.Threading.Tasks; + +class BrowserExamples +{ + public static async Task Main() + { + using var playwright = await Playwright.CreateAsync(); + var firefox = playwright.Firefox; + var browser = await firefox.LaunchAsync(headless: false); + var page = await browser.NewPageAsync(); + await page.GoToAsync("https://www.bing.com"); + await browser.CloseAsync(); + } +} +``` + ## event: Browser.disconnected - argument: <[Browser]> @@ -112,6 +130,14 @@ context = browser.new_context() print(len(browser.contexts())) # prints `1` ``` +```csharp +using var playwright = await Playwright.CreateAsync(); +var browser = await playwright.Webkit.LaunchAsync(); +System.Console.WriteLine(browser.Contexts.Count); // prints "0" +var context = await browser.NewContextAsync(); +System.Console.WriteLine(browser.Contexts.Count); // prints "1" +``` + ## method: Browser.isConnected - returns: <[boolean]> @@ -170,6 +196,16 @@ page = context.new_page() page.goto("https://example.com") ``` +```csharp +using var playwright = await Playwright.CreateAsync(); +var browser = await playwright.Firefox.LaunchAsync(); +// Create a new incognito browser context. +var context = await browser.NewContextAsync(); +// Create a new page in a pristine context. +var page = await context.NewPageAsync(); ; +await page.GoToAsync("https://www.bing.com"); +``` + ### option: Browser.newContext.-inline- = %%-shared-context-params-list-%% ### option: Browser.newContext.proxy = %%-context-option-proxy-%%