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();
});
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeStep;
var scenario = LoadStrikeScenario.create("playwright-login", context ->
LoadStrikeStep.run("login", context, () -> {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(true));
Page page = browser.newPage();
page.navigate("https://example.com/login");
page.fill("#email", "[email protected]");
page.click("button[type='submit']");
browser.close();
return LoadStrikeResponse.ok("200");
}
}).asReply()
);
from playwright.sync_api import sync_playwright
from loadstrike_sdk import LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep
def run_login():
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=True)
page = browser.new_page()
try:
page.goto("https://example.com/login")
page.fill("#email", "[email protected]")
page.click("button[type='submit']")
return LoadStrikeResponse.ok("200")
finally:
browser.close()
scenario = LoadStrikeScenario.create(
"playwright-login",
lambda context: LoadStrikeStep.run("login", context, run_login)["as_reply"](),
)
import { chromium } from "playwright";
import { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } from "@loadstrike/loadstrike-sdk";
const scenario = LoadStrikeScenario.create("playwright-login", async (context) => {
return LoadStrikeStep.run("login", context, async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
try {
await page.goto("https://example.com/login");
await page.fill("#email", "[email protected]");
await page.click("button[type='submit']");
return LoadStrikeResponse.ok("200");
} finally {
await browser.close();
}
});
});
const { chromium } = require("playwright");
const { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } = require("@loadstrike/loadstrike-sdk");
const scenario = LoadStrikeScenario.create("playwright-login", async (context) => {
return LoadStrikeStep.run("login", context, async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
try {
await page.goto("https://example.com/login");
await page.fill("#email", "[email protected]");
await page.click("button[type='submit']");
return LoadStrikeResponse.ok("200");
} finally {
await browser.close();
}
});
});
Pattern
Launch the browser or shared automation resources before the scenario starts running copies.
Execute the UI journey inside a named step so status and latency are tracked like any other business operation.
Close the browser and release resources when the scenario instance finishes.