Interface IPlaywright
- Namespace
- Microsoft.Playwright
- Assembly
- Microsoft.Playwright.dll
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...
}
}
public interface IPlaywright : IDisposable
- Inherited Members
Properties
APIRequest
Exposes API that can be used for the Web API testing.
IAPIRequest APIRequest { get; }
Property Value
Chromium
This object can be used to launch or connect to Chromium, returning instances of IBrowser.
IBrowserType Chromium { get; }
Property Value
Devices
Returns a dictionary of devices to be used with NewContextAsync(BrowserNewContextOptions?) or NewPageAsync(BrowserNewPageOptions?).
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...
}
}
IReadOnlyDictionary<string, BrowserNewContextOptions> Devices { get; }
Property Value
Firefox
This object can be used to launch or connect to Firefox, returning instances of IBrowser.
IBrowserType Firefox { get; }
Property Value
this[string]
Gets a IBrowserType.
IBrowserType this[string browserType] { get; }
Parameters
browserType
stringIBrowserType name. You can get the names from BrowserType. e.g.: Chromium, Firefox or Webkit.
Property Value
Selectors
Selectors can be used to install custom selector engines. See extensibility for more information.
ISelectors Selectors { get; }
Property Value
Webkit
This object can be used to launch or connect to WebKit, returning instances of IBrowser.
IBrowserType Webkit { get; }