Skip to main content
Version: 1.12.0

Playwright

Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright to drive automation:

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...
}
}

Playwright.Chromium#

This object can be used to launch or connect to Chromium, returning instances of Browser.

Playwright.Devices#

  • type: <[IReadOnlyDictionary]<string, [BrowserNewContextOptions]>>

Returns a dictionary of devices to be used with Browser.NewContextAsync(options) or Browser.NewPageAsync(options).

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...
}
}

Playwright.Firefox#

This object can be used to launch or connect to Firefox, returning instances of Browser.

Playwright.Selectors#

Selectors can be used to install custom selector engines. See Working with selectors for more information.

Playwright.Webkit#

This object can be used to launch or connect to WebKit, returning instances of Browser.