Skip to content

Playwright ​

Added in: v1.8

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

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

Properties ​

Playwright.APIRequest ​

Added in: v1.16

Exposes API that can be used for the Web API testing.

Type

  • APIRequest

Playwright.Chromium ​

Added in: v1.8

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

Type

  • BrowserType

Playwright.Devices ​

Added in: v1.8

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

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

Type

  • IReadOnlyDictionary<string, BrowserNewContextOptions>

Playwright.Firefox ​

Added in: v1.8

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

Type

  • BrowserType

Playwright.Selectors ​

Added in: v1.8

Selectors can be used to install custom selector engines. See extensibility for more information.

Type

  • Selectors

Playwright.Webkit ​

Added in: v1.8

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

Type

  • BrowserType

Released under the Apache 2.0 License.