Class WebSessionAttribute

Namespace
ProtoTest.Web
Assembly
ProtoTest.Web.dll

Declares a named web session for the test during setup, created on demand like any other session. Optionally navigates it to a start URL. Combine with LoginAsAttribute<TStrategy> when the session also needs authentication; use Order to sequence the two if needed.

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

Examples

[WebSession("Admin", Open = "https://app.test/back-office")]
[WebSession("Customer")]
[LoginAs<BackOfficeLogin>("billing.admin", Session = "Admin")]
public async Task ...() { ... }

Constructors

WebSessionAttribute(string)

public WebSessionAttribute(string name)

Parameters

name string

Properties

Application

Gets or sets the application this session targets. Defaults to ProtoTest:Web:Sessions:{name}:Application, then the session name.

public string? Application { get; init; }

Property Value

string

Name

Gets the session name, matching Proto.Context.Web(name) and LoginAs(Session = ...).

public string Name { get; }

Property Value

string

Open

Gets or sets an optional absolute or relative URL to navigate this session to during setup.

public string? Open { get; init; }

Property Value

string

Methods

BeforeTestAsync(ProtoExecutionContext)

Executed asynchronously before the decorated test or class tests execute.

public override Task BeforeTestAsync(ProtoExecutionContext context)

Parameters

context ProtoExecutionContext

Returns

Task