Playwright UI Load Guide

Run browser-based UI workflows under controlled load by executing Playwright flows inside LoadStrike scenarios.

Integration Model

LoadStrike does not require a special Playwright adapter. Use LoadStrikeScenario and LoadStrikeStep to run Playwright browser actions directly inside scenario run delegates.

Dependencies

Add Microsoft.Playwright package to your test project and install browser binaries before execution. Launch browser once in WithInit, execute page flows in steps, and close resources in WithClean.

Load Strategy

Use lower copy counts than protocol tests because each browser context is heavier than HTTP requests. KeepConstant and Inject simulations are typically used for sustained UI flow load.

Result Mapping

Map successful UI outcomes to LoadStrikeResponse.Ok and map assertion/navigation/timeouts to LoadStrikeResponse.Fail with meaningful status codes such as UI_ASSERTION_FAILED or UI_TIMEOUT.

Reporting

UI scenario runs use the same report model as other scenarios: summary, step measurements, status code distribution, failures, and latency percentiles in HTML/CSV/TXT/Markdown outputs.

Cluster Execution

For distributed UI load, run scenarios on coordinator and agents with NATS cluster mode. Ensure container images include browser binaries and required OS dependencies for headless Playwright.

Feature Usage Samples

How to use snippets for Playwright UI Load Guide.

Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.

Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.

Playwright UI Step

using Microsoft.Playwright;

var scenario = LoadStrikeScenario.Create("playwright-login", async context =>
{
    var step = await LoadStrikeStep.Run<string>("login", context, async () =>
    {
        await using var playwright = await Playwright.CreateAsync();
        await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true });
        var page = await browser.NewPageAsync();

        await page.GotoAsync("https://example.com/login");
        await page.FillAsync("#email", "[email protected]");
        await page.ClickAsync("button[type='submit']");

        return LoadStrikeResponse.Ok<string>(statusCode: "200");
    });

    return step.AsReply();
});

Pattern

WithInit

Launch the browser or shared automation resources before the scenario starts running copies.

LoadStrikeStep

Execute the UI journey inside a named step so status and latency are tracked like any other business operation.

WithClean

Close the browser and release resources when the scenario instance finishes.