Selenium UI Load Guide
Run browser-based UI workflows under controlled load by executing Selenium flows inside LoadStrike scenarios.
Integration Model
LoadStrike does not require a special Selenium adapter. Use LoadStrikeScenario and LoadStrikeStep to run Selenium WebDriver actions directly inside scenario run delegates.
Dependencies
Add the Selenium package for your language and install a compatible browser driver such as ChromeDriver or geckodriver before execution. Create the driver in WithInit when you want to reuse browser sessions, run page flows in steps, and close resources in WithClean or finally blocks.
Load Strategy
Use lower copy counts than protocol tests because each browser session 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, element lookup, navigation, or timeout failures 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 the browser, driver binaries, and required OS dependencies for headless Selenium execution.
Feature Usage Samples
How to use snippets for Selenium 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.
Selenium UI Step
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
var scenario = LoadStrikeScenario.Create("ui-login", async context =>
{
var step = await LoadStrikeStep.Run<string>("login", context, () =>
{
var options = new ChromeOptions();
options.AddArgument("--headless=new");
using var driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("https://example.com/login");
driver.FindElement(By.Id("email")).SendKeys("[email protected]");
driver.FindElement(By.CssSelector("button[type='submit']")).Click();
return Task.FromResult(LoadStrikeResponse.Ok<string>(statusCode: "200"));
});
return step.AsReply();
});
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeResponse;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeScenario;
import com.loadstrike.runtime.LoadStrikeRuntime.LoadStrikeStep;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
var scenario = LoadStrikeScenario.create(
"ui-login",
context -> LoadStrikeStep.run("login", context, () -> {
var options = new ChromeOptions();
options.addArguments("--headless=new");
var driver = new ChromeDriver(options);
try {
driver.get("https://example.com/login");
driver.findElement(By.id("email")).sendKeys("[email protected]");
driver.findElement(By.cssSelector("button[type='submit']")).click();
return LoadStrikeResponse.ok("200");
} finally {
driver.quit();
}
}).asReply()
);
from selenium import webdriver
from selenium.webdriver.common.by import By
from loadstrike_sdk import LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep
def run_login():
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com/login")
driver.find_element(By.ID, "email").send_keys("[email protected]")
driver.find_element(By.CSS_SELECTOR, "button[type='submit']").click()
return LoadStrikeResponse.ok("200")
finally:
driver.quit()
scenario = LoadStrikeScenario.create(
"ui-login",
lambda context: LoadStrikeStep.run("login", context, run_login)["as_reply"](),
)
import { Builder, Browser, By } from "selenium-webdriver";
import chrome from "selenium-webdriver/chrome";
import { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } from "@loadstrike/loadstrike-sdk";
const scenario = LoadStrikeScenario.create("ui-login", async (context) => {
return LoadStrikeStep.run("login", context, async () => {
const options = new chrome.Options().addArguments("--headless=new");
const driver = await new Builder()
.forBrowser(Browser.CHROME)
.setChromeOptions(options)
.build();
try {
await driver.get("https://example.com/login");
await driver.findElement(By.id("email")).sendKeys("[email protected]");
await driver.findElement(By.css("button[type='submit']")).click();
return LoadStrikeResponse.ok("200");
} finally {
await driver.quit();
}
});
});
const { Builder, Browser, By } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const { LoadStrikeResponse, LoadStrikeScenario, LoadStrikeStep } = require("@loadstrike/loadstrike-sdk");
const scenario = LoadStrikeScenario.create("ui-login", async (context) => {
return LoadStrikeStep.run("login", context, async () => {
const options = new chrome.Options().addArguments("--headless=new");
const driver = await new Builder()
.forBrowser(Browser.CHROME)
.setChromeOptions(options)
.build();
try {
await driver.get("https://example.com/login");
await driver.findElement(By.id("email")).sendKeys("[email protected]");
await driver.findElement(By.css("button[type='submit']")).click();
return LoadStrikeResponse.ok("200");
} finally {
await driver.quit();
}
});
});
Pattern
Install Selenium and a browser driver that matches the browser you want to automate.
Create the driver in WithInit for reuse or inside the step when each iteration should own its browser lifecycle.
Run the UI journey inside a named step so the workflow is measured and reported as part of the scenario.
Dispose the driver in WithClean or a finally block so browsers do not accumulate between iterations.