se-driver-manager
Sets up browser driver management with Selenium Manager (built-in) or WebDriverManager, browser options, and a thread-safe driver factory. Use when an SDET says "set up my WebDriver", "I keep getting driver version mismatch", "make a thread-safe driver factory", "configure ChromeOptions headless", or wants clean driver lifecycle for parallel runs. Produces code the engineer runs.
- License 许可
- MIT
- 最近更新
- 2026-07-15
- Stars
- ★ 4
- Forks
- 8
01 前言 Front Matter
- name
- se-driver-manager
- license
- MIT
- metadata
- { "pack": "selenium", "author": "TheTestingAcademy", "version": "1.0.0" }
- description
- Sets up browser driver management with Selenium Manager (built-in) or WebDriverManager, browser options, and a thread-safe driver factory. Use when an SDET says "set up my WebDriver", "I keep getting driver version mismatch", "make a thread-safe driver factory", "configure ChromeOptions headless", or wants clean driver lifecycle for parallel runs. Produces code the engineer runs.
03 SKILL.md 正文
Selenium Driver Manager
You set up driver resolution, browser options, and a thread-safe lifecycle. The factory code is a draft the engineer must run; driver/browser availability depends on their machine.
When to use
- A project hits driver/browser version mismatches or manual
chromedriverpaths. - Someone wants headless, incognito, or custom
ChromeOptions/FirefoxOptions. - Parallel TestNG runs need per-thread isolated drivers (
ThreadLocal).
Workflow
- Choose resolution: Selenium Manager (built-in to Selenium 4.6+, zero config —
just
new ChromeDriver()) or WebDriverManager (WebDriverManager.chromedriver().setup()) when you need pinning/proxy/mirror control. Recommend Selenium Manager by default. - Build browser options per browser: headless mode (
--headless=new), window size, download prefs, disabling notifications — keep them in one place. - Create a thread-safe factory using
ThreadLocal<WebDriver>so parallel tests each get an isolated session; exposegetDriver()andquitDriver(). - Select browser by config (system property/env var) so the same factory serves Chrome/Firefox/Edge.
- Guarantee cleanup:
quitDriver()callsquit()andremove()from the ThreadLocal to avoid leaks across threads. - Emit the factory + options, noting which browsers you could not verify installed.
Output shape
public final class DriverFactory {
private static final ThreadLocal<WebDriver> TL = new ThreadLocal<>();
public static WebDriver getDriver() {
if (TL.get() == null) TL.set(create(System.getProperty("browser", "chrome")));
return TL.get();
}
private static WebDriver create(String browser) {
switch (browser.toLowerCase()) {
case "firefox":
return new FirefoxDriver(new FirefoxOptions());
case "edge":
return new EdgeDriver(new EdgeOptions());
default: // Selenium Manager auto-resolves the driver
ChromeOptions opts = new ChromeOptions();
if (Boolean.getBoolean("headless")) opts.addArguments("--headless=new", "--window-size=1920,1080");
return new ChromeDriver(opts);
}
}
public static void quitDriver() {
if (TL.get() != null) { TL.get().quit(); TL.remove(); } // remove() prevents thread leaks
}
}
Guardrails
- This factory is a draft the engineer must run — driver resolution can fail on machines without the target browser installed.
- Never assume a locator exists in example usage; the factory returns a driver only, tests supply real selectors.
- Prefer Selenium Manager over hardcoded driver paths or
System.setProperty("webdriver.chrome.driver", ...). - Always
remove()the ThreadLocal in cleanup — a lingering entry leaks a session into the next test on that thread. - Don't share one static
WebDriveracross parallel threads; that is the classic cause of cross-talk flakiness. - Do not fabricate installed browser versions; if you can't confirm one, say the engineer must verify it.
04 同仓库更多 Skills
se-wait-fixer
Scans Selenium Java code for Thread.sleep and for implicit+explicit wait mixing, then replaces them with WebDriverWait/ExpectedConditions or FluentWait to fix synchronization. Use when an SDET says "remove Thread.sleep from my tests", "fix the flaky waits", "my implicit and explicit waits conflict", or pastes code full of hard sleeps. Produces refactors the engineer must run and confirm.
se-test-generator
Generates a runnable Selenium 4 + TestNG test in Java from a plain-language scenario, using explicit waits and stable locators. Use when an SDET says "write a Selenium test for login", "generate a TestNG test for the checkout flow", "automate this scenario in Selenium", or pastes Gherkin/steps and wants Java WebDriver code. Produces a draft test the engineer must review and run.
se-report-integrator
Integrates reporting (Allure or ExtentReports) into a Selenium + TestNG suite with listeners, screenshot-on-failure, and step logging. Use when an SDET says "add Allure to my tests", "set up ExtentReports", "capture a screenshot on failure", "add a TestNG listener for reporting", or wants readable run reports. Produces listener and config code the engineer must run to generate a report.
se-page-object-builder
Builds a Page Object Model class in Java (PageFactory @FindBy or explicit locators) with action methods and a WebDriverWait for a given page. Use when an SDET says "create a page object for the login page", "build a POM class", "refactor these locators into a page object", or pastes a page's fields and wants a reusable POM. Produces a draft class the engineer must review and run.
se-locator-strategist
Recommends and repairs Selenium locator strategy — replaces brittle absolute XPath with By.id, By.cssSelector, or Selenium 4 relative locators, and explains the trade-offs. Use when an SDET says "this XPath keeps breaking", "make this locator more stable", "why is my locator flaky", "convert this XPath to CSS", or pastes selectors to harden. Produces proposals the engineer must verify in the DOM.
se-grid-configurator
Configures Selenium Grid 4 (hub-and-node or standalone, including Docker) and wires RemoteWebDriver for parallel and distributed runs. Use when an SDET says "set up Selenium Grid", "run my tests on a remote grid", "dockerize Selenium Grid 4", "point my tests at RemoteWebDriver", or wants parallel execution across nodes. Produces config and code the engineer must run and validate in their environment.