Class RequiresPlaywrightBrowserAttribute

Namespace
ProtoTest.Web.Playwright
Assembly
ProtoTest.Web.Playwright.dll

Skips the test when the Playwright browser it needs cannot run here. Unlike RequiresCapabilityAttribute, which only proves AddWeb was called, this condition probes the installed browser before the lifecycle starts - without launching one.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class RequiresPlaywrightBrowserAttribute : ProtoAttribute, IProtoSkipCondition
Inheritance
RequiresPlaywrightBrowserAttribute
Implements
Inherited Members
Extension Methods

Examples

[RequiresPlaywrightBrowser]                                   // the configured browser
[RequiresPlaywrightBrowser(browser: PlaywrightBrowser.Firefox)]
[RequiresPlaywrightBrowser(channel: "msedge", Reason = "No Edge in this environment.")]
[RequiresPlaywrightBrowser(Session = "Admin")]                // the Admin session's options
public async Task ...() { ... }

Remarks

The probe reads the host's Playwright options - the AddWeb(...) callback supplies their defaults, configuration overrides them - so it respects InstallBrowsers and Channel. A browser that can run produces no skip; a missing one produces a reason naming Playwright and the install options. A channel that Playwright recognizes is accepted as is: channels name a system browser, which only a real launch can resolve, so the condition cannot prove one absent.

Constructors

RequiresPlaywrightBrowserAttribute()

Requires the host's configured browser.

public RequiresPlaywrightBrowserAttribute()

RequiresPlaywrightBrowserAttribute(PlaywrightBrowser)

public RequiresPlaywrightBrowserAttribute(PlaywrightBrowser browser)

Parameters

browser PlaywrightBrowser

The browser to require; defaults to the host's configured browser.

RequiresPlaywrightBrowserAttribute(string)

public RequiresPlaywrightBrowserAttribute(string channel)

Parameters

channel string

A system browser channel to require (for example msedge or chrome); defaults to the host's configured channel.

Properties

Browser

The required browser, or null to use the host's configured browser.

public PlaywrightBrowser? Browser { get; }

Property Value

PlaywrightBrowser?

Channel

The required system browser channel, or null to use the host's configuration.

public string? Channel { get; }

Property Value

string

Reason

The reason reported when the browser cannot run.

public string? Reason { get; init; }

Property Value

string

Session

The session whose options the probe follows, or null for the protocol-level section. Set it when the test drives a named session, because the backend binds ProtoTest:Web:Sessions:{name} over ProtoTest:Web:Playwright; without it a session-level browser, channel or install-browsers setting could disagree with the launch.

public string? Session { get; init; }

Property Value

string

Methods

GetSkipReason(ProtoHost)

Returns the reason to skip, or null when the test can run.

public string? GetSkipReason(ProtoHost host)

Parameters

host ProtoHost

Returns

string