Class WebSessionAttribute
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
namestring
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
Name
Gets the session name, matching Proto.Context.Web(name) and LoginAs(Session = ...).
public string Name { get; }
Property Value
Open
Gets or sets an optional absolute or relative URL to navigate this session to during setup.
public string? Open { get; init; }
Property Value
Methods
BeforeTestAsync(ProtoExecutionContext)
Executed asynchronously before the decorated test or class tests execute.
public override Task BeforeTestAsync(ProtoExecutionContext context)
Parameters
contextProtoExecutionContext