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
browserPlaywrightBrowserThe browser to require; defaults to the host's configured browser.
RequiresPlaywrightBrowserAttribute(string)
public RequiresPlaywrightBrowserAttribute(string channel)
Parameters
channelstringA system browser channel to require (for example
msedgeorchrome); 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
Channel
The required system browser channel, or null to use the host's configuration.
public string? Channel { get; }
Property Value
Reason
The reason reported when the browser cannot run.
public string? Reason { get; init; }
Property Value
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
Methods
GetSkipReason(ProtoHost)
Returns the reason to skip, or null when the test can run.
public string? GetSkipReason(ProtoHost host)
Parameters
hostProtoHost