Selenium Cross-Browser Runner
You wire tests to run across multiple browsers via TestNG parameters/factory and
a browser matrix. The setup is a draft the engineer must actually run on each browser
— you cannot confirm every browser is installed or behaves identically.
When to use
- The same suite must execute on Chrome, Firefox, and/or Edge.
- Someone wants the browser selectable from
testng.xml or a system property.
- A CI browser matrix (browser × maybe version/OS) needs defining.
Workflow
- Authorize the matrix run: confirm an approved non-production target, synthetic
owned identity/data, allowed side effects, cleanup/reset behavior, selected browsers,
finite run count, concurrency, resource ceiling, and abort conditions.
- Parameterize the browser: a
@Parameters("browser") value from testng.xml,
or a @Factory that instantiates the test class once per browser.
- Route to a driver factory that maps the parameter to
ChromeDriver/
FirefoxDriver/EdgeDriver with per-browser options (reuse se-driver-manager).
- Define suite blocks in
testng.xml — one <test> per browser. Start serially;
enable parallel="tests" only when the approved target, test data, cleanup, and
infrastructure can safely support the chosen concurrency.
- Keep tests browser-agnostic: no browser-specific locators or waits; differences
go in options only.
- Add a matrix note for CI (e.g. GitHub Actions strategy matrix) so the same suite
fans out across browsers.
- Emit
testng.xml + factory glue and list browsers you could not verify installed.
- HUMAN REVIEW GATE (mandatory). Stop before execution until a human approves
the target/data, side effects, cleanup, browser/run matrix, concurrency, ceilings,
abort conditions, and any retained evidence.
Output shape
<!-- safe default: one browser at a time; parallelism requires explicit approval -->
<suite name="cross-browser" parallel="false" thread-count="1">
<test name="chrome"> <parameter name="browser" value="chrome"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>
<test name="firefox"> <parameter name="browser" value="firefox"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>
<test name="edge"> <parameter name="browser" value="edge"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>
</suite>
public class BaseTest {
protected WebDriver driver;
@Parameters("browser")
@BeforeMethod
public void setUp(@Optional("chrome") String browser) {
driver = DriverFactory.create(browser); // maps param -> Chrome/Firefox/Edge (+ options)
}
@AfterMethod
public void tearDown() { if (driver != null) driver.quit(); }
}
Guardrails
- This is a draft the engineer must run on each browser — passing on Chrome does not prove Firefox/Edge pass.
- Never assume a locator exists, and never write browser-specific locators; a matrix only works if tests are browser-agnostic.
- Don't fabricate that a browser is installed; if you can't confirm Edge/Firefox availability, say the engineer must verify.
- Keep browser differences confined to driver options — not to test logic or waits.
- Size
thread-count to real machine capacity; over-parallelizing browsers causes flakiness.
- Always
quit() each browser session to avoid leaking processes across the matrix.
- Never fan out state-changing tests without approved target, owned synthetic data, effects,
cleanup, run/concurrency limits, and abort conditions. Stop on unexpected external effects.
1---2name: se-cross-browser-runner3description: Sets up cross-browser Selenium execution across Chrome, Firefox, and Edge via TestNG parameters or a factory, plus a browser matrix. Use when an SDET says "run my tests on Chrome and Firefox", "add cross-browser support", "parameterize the browser in testng.xml", "set up a browser matrix", or wants multi-browser CI runs. Produces config and code the engineer must run per browser to confirm.4license: MIT5---67# Selenium Cross-Browser Runner89You **wire tests to run across multiple browsers** via TestNG parameters/factory and10a browser matrix. The setup is a draft the engineer must actually run on each browser11— you cannot confirm every browser is installed or behaves identically.1213## When to use14- The same suite must execute on Chrome, Firefox, and/or Edge.15- Someone wants the browser selectable from `testng.xml` or a system property.16- A CI browser matrix (browser × maybe version/OS) needs defining.1718## Workflow191. **Authorize the matrix run**: confirm an approved non-production target, synthetic20 owned identity/data, allowed side effects, cleanup/reset behavior, selected browsers,21 finite run count, concurrency, resource ceiling, and abort conditions.222. **Parameterize the browser**: a `@Parameters("browser")` value from `testng.xml`,23 or a `@Factory` that instantiates the test class once per browser.243. **Route to a driver factory** that maps the parameter to `ChromeDriver`/25 `FirefoxDriver`/`EdgeDriver` with per-browser options (reuse `se-driver-manager`).264. **Define suite blocks** in `testng.xml` — one `<test>` per browser. Start serially;27 enable `parallel="tests"` only when the approved target, test data, cleanup, and28 infrastructure can safely support the chosen concurrency.295. **Keep tests browser-agnostic**: no browser-specific locators or waits; differences30 go in options only.316. **Add a matrix note** for CI (e.g. GitHub Actions strategy matrix) so the same suite32 fans out across browsers.337. **Emit** `testng.xml` + factory glue and list browsers you could not verify installed.348. **HUMAN REVIEW GATE (mandatory).** Stop before execution until a human approves35 the target/data, side effects, cleanup, browser/run matrix, concurrency, ceilings,36 abort conditions, and any retained evidence.3738## Output shape39```xml40<!-- safe default: one browser at a time; parallelism requires explicit approval -->41<suite name="cross-browser" parallel="false" thread-count="1">42 <test name="chrome"> <parameter name="browser" value="chrome"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>43 <test name="firefox"> <parameter name="browser" value="firefox"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>44 <test name="edge"> <parameter name="browser" value="edge"/> <classes><class name="com.qa.tests.LoginTest"/></classes></test>45</suite>46```47```java48public class BaseTest {49 protected WebDriver driver;5051 @Parameters("browser")52 @BeforeMethod53 public void setUp(@Optional("chrome") String browser) {54 driver = DriverFactory.create(browser); // maps param -> Chrome/Firefox/Edge (+ options)55 }5657 @AfterMethod58 public void tearDown() { if (driver != null) driver.quit(); }59}60```6162## Guardrails63- This is a **draft the engineer must run on each browser** — passing on Chrome does not prove Firefox/Edge pass.64- **Never assume a locator exists**, and never write browser-specific locators; a matrix only works if tests are browser-agnostic.65- Don't fabricate that a browser is installed; if you can't confirm Edge/Firefox availability, say the engineer must verify.66- Keep browser differences confined to driver options — not to test logic or waits.67- Size `thread-count` to real machine capacity; over-parallelizing browsers causes flakiness.68- Always `quit()` each browser session to avoid leaking processes across the matrix.69- Never fan out state-changing tests without approved target, owned synthetic data, effects,70 cleanup, run/concurrency limits, and abort conditions. Stop on unexpected external effects.