Lyo.Web.Automation.Playwright 2.0.0

dotnet add package Lyo.Web.Automation.Playwright --version 2.0.0
                    
NuGet\Install-Package Lyo.Web.Automation.Playwright -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lyo.Web.Automation.Playwright" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lyo.Web.Automation.Playwright" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Lyo.Web.Automation.Playwright" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lyo.Web.Automation.Playwright --version 2.0.0
                    
#r "nuget: Lyo.Web.Automation.Playwright, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lyo.Web.Automation.Playwright@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lyo.Web.Automation.Playwright&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Lyo.Web.Automation.Playwright&version=2.0.0
                    
Install as a Cake Tool

Lyo.Web.Automation.Playwright

Playwright backend for the Lyo.Web.Automation abstractions: launches Chromium / Firefox / WebKit, owns session-scoped browser contexts, and exposes the same tab, frame, dialog, keyboard, and locator helpers as Lyo.Web.Automation.Selenium so JSON automation plans and scripted runners behave the same on both engines.

Examples

First steps

services.AddPlaywrightBrowserServiceFromConfiguration(builder.Configuration);

// per operation:
var service = sp.GetRequiredService<IPlaywrightBrowserService>();
using var session = service.CreateSession();
await session.StartBrowserAsync();
await session.Browser.NavigateAsync("https://example.com");
// Playwright does not reference Lyo.Http.Client. Copy UA/cookies in the host (see Lyo.TestConsole).
using var session = playwright.CreateSession(o => {
    o.BrowserKind = PlaywrightBrowserKind.Chromium;
    if (!string.IsNullOrWhiteSpace(flared.Session.UserAgent))
        o.UserAgents = [flared.Session.UserAgent];
    o.ProxyUrl = flaredOpts.ProxyUrl;
});
await session.StartBrowserAsync();
await session.Browser.CookieJar!.AddCookiesAsync(
    flared.Session.CookieJar.Export().Select(c => new BrowserCookie {
        Name = c.Name, Value = c.Value, Domain = c.Domain, Path = c.Path,
        Secure = c.Secure, HttpOnly = c.HttpOnly, Expiry = c.Expiry
    }));
await session.Browser.NavigateToAsync(url);

Browser layer (Browser/)

  • PlaywrightBrowser. Concrete IWebAutomationBrowser (StartBrowserAsync boots Playwright and a default page); composes PlaywrightBrowserTabs, PlaywrightDialogs, PlaywrightKeyboard, PlaywrightFrameNavigator, PlaywrightFrameSelectors, PlaywrightCookieJar, PlaywrightHeaderStore.
  • PlaywrightTabManager / PlaywrightBrowserTabInfo. Engine-native tab info and management.
  • BrowserUrlRedaction. Query/fragment redaction used in logs when MaskSensitiveUrlsInLogs is set.
  • PlaywrightWebAutomationElement. Playwright ILocator adapter for IWebAutomationElement (ClickAsync, SendKeysAsync with Fill / PressSequentially, SendKeysRawAsync, attribute reads, etc.).
  • PlaywrightLocatorFactory (PlaywrightLocatorFactory.cs). Maps Lyo.Web.Automation element specs onto Playwright locators.
  • Cloudflare handoff is host-owned. This package does not reference Lyo.Http.Client. After a Flared solve, the host copies solver UA onto PlaywrightBrowserOptions.UserAgents (Chromium only), the same ProxyUrl onto the context, and ILyoHttpCookieJar entries onto CookieJar. Worked example: FlaredPlaywrightHandoff.cs. Architecture: HttpClientArchitecture.drawio.

Service layer (Service/)

  • IPlaywrightBrowserService. Singleton factory: CreateSession() clones service config (including BrowserKind); CreateSession(Action<PlaywrightBrowserOptions>) overlays on that clone (pin UA without resetting Firefox/Chromium). CreateSession(new PlaywrightSessionOptions()) is a full replace and defaults to Chromium. ActiveSessionCount, Dispose.
  • IPlaywrightBrowserSession. Scoped session.
  • PlaywrightExecutionContextFactory / PlaywrightExecutionContext. Wiring used by the automation runners.
  • PlaywrightMetricTags. Constants for metric tags.

Settings (Configuration/)

Application-wide defaults live on PlaywrightBrowserOptions; PlaywrightSessionOptions is the per-session subclass passed to CreateSession. Configuration section: "PlaywrightBrowserOptions".

Property Default Notes
BrowserKind Chromium PlaywrightBrowserKind: Chromium, Firefox, Webkit. Firefox is Playwright Nightly. Flared handoff requires Chromium.
Headless false Launch headless where the engine allows it.
Channel null Optional Playwright channel (msedge, chrome, …). Chromium only; ignored for Firefox/WebKit.
ProxyUrl null Browser-context proxy. Copy FlaredHttpOptions.ProxyUrl so cf_clearance stays same-IP.
LaunchArguments --disable-infobars, --disable-extensions, --disable-dev-shm-usage, --no-sandbox (Chromium only) Every entry must start with - (ResolveLaunchArguments throws otherwise). Adds --window-size for Chromium only. Firefox/WebKit drop Chromium defaults: Playwright treats unknown tokens as start URLs (http://1920,1080). --disable-gpu is omitted (SwiftShader tell).
UserAgents one Chrome UA on Linux First entry is used as the context User-Agent. Firefox/WebKit skip the default Chrome UA and keep the engine UA.
ViewportWidth/Height 1920 × 1080 Starting layout viewport (window.innerWidth / innerHeight).
ScreenWidth/Height 1920 × 1080 Playwright ScreenSize (window.screen). Headless Chromium reports 800×600 unless this is set. Must be ≥ viewport.
RandomizeViewportOnSessionStart false When true, pick from ViewportSizes (or DesktopDisplaySize.Common) once at StartBrowserAsync and set both viewport and screen. Tests should leave this false.
ViewportSizes / ViewportJitterPixels [] / 0 Pool and optional ±pixel jitter for session-start randomization. Prefer discrete common sizes over jitter.
NavigationWaitUntil DOMContentLoaded Playwright waitUntil for goto/reload. Cloudflare interstitials often never fire load. Set Load only when every subresource must finish.
NavigationTimeoutMs 30 000 Default navigation timeout (ms).
LocatorDefaultTimeoutMs 30 000 Default timeout for locator actions and the PollForElementAsync family.
PollingMaxAttempts / PollingDelayBetweenAttempts 5 / 500 ms Controls the outer poll-retry loop.
EnableMetrics true When an IMetrics is registered, emit instrumentation.
SlowMoMilliseconds 0 Delay between Playwright operations (slow motion).
IgnoreHttpsErrors false The browser context ignores HTTPS errors.
CloseOwnedResourcesOnDispose true Whether dispose closes StartBrowserAsync ownership.
MaskSensitiveUrlsInLogs false Drop query/fragment from log lines.
ServiceRootDirectory {tmp}/lyo-playwright Each session creates session-{id}/ with artifacts/, browser-profile/, downloads/.
BrowserUserDataDirectory / DownloadDirectory / ArtifactsDirectory derived under the session directory Override per field if needed.
Clone() n/a Deep copy used to derive session-specific options.

DI registration (Service/PlaywrightServiceExtensions.cs)

Method Registers
AddPlaywrightBrowser(Action<PlaywrightBrowserOptions>?) Singleton options plus scoped PlaywrightBrowser for direct injection.
AddPlaywrightBrowser(PlaywrightBrowserOptions) Same, with an explicit options instance.
AddPlaywrightBrowserService(Action<PlaywrightBrowserOptions>?) Above plus singleton IPlaywrightBrowserService (use this for session-based usage via CreateSession).
AddPlaywrightBrowserService(PlaywrightBrowserOptions) Same, with explicit options.
AddPlaywrightBrowserServiceFromConfiguration(IConfiguration, configSectionName?) Binds options from configuration (default section "PlaywrightBrowserOptions").

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Common.Core (direct, lyo)
  • Lyo.IO.Temp (direct, lyo)
  • Lyo.Web.Automation (direct, lyo)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (direct, microsoft, netstandard2.0)
  • Microsoft.Extensions.Configuration.Binder 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 (direct, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (direct, microsoft)
  • Microsoft.Playwright 1.59.0 (direct, microsoft)
  • System.Text.Json 10.0.5 (direct, microsoft, netstandard2.0)
  • Lyo.Common.Metadata (transitive, lyo)
  • Lyo.Configuration (transitive, lyo)
  • Lyo.Exceptions (transitive, lyo)
  • Lyo.Formatter (transitive, lyo)
  • Lyo.Metrics (transitive, lyo)
  • Lyo.Parameters (transitive, lyo)
  • DynamicExpresso.Core 2.19.3 (transitive, third-party)
  • Microsoft.Extensions.Hosting.Abstractions 10.0.5 (transitive, microsoft)
  • SmartFormat.NET 3.6.1 (transitive, third-party)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 65 9/9/2026
1.0.13 97 8/25/2026
1.0.11 95 8/23/2026
1.0.9 98 8/22/2026
1.0.6 108 8/20/2026
1.0.4 111 8/20/2026
1.0.3 93 8/19/2026
1.0.2 95 8/19/2026
1.0.1 98 8/18/2026
1.0.0 105 8/16/2026