se-flaky-debugger
Diagnoses flaky Selenium tests — StaleElementReferenceException, timing and synchronization races, dynamic/late-rendering elements — and proposes robust fixes. Use when an SDET says "my test is flaky", "StaleElementReferenceException keeps happening", "passes locally fails in CI", "intermittent NoSuchElement", or pastes a stack trace. Produces fixes the engineer must run to confirm the cure.
- License 许可
- MIT
- 最近更新
- 2026-07-15
- Stars
- ★ 4
- Forks
- 8
01 前言 Front Matter
- name
- se-flaky-debugger
- license
- MIT
- metadata
- { "pack": "selenium", "author": "TheTestingAcademy", "version": "1.0.0" }
- description
- Diagnoses flaky Selenium tests — StaleElementReferenceException, timing and synchronization races, dynamic/late-rendering elements — and proposes robust fixes. Use when an SDET says "my test is flaky", "StaleElementReferenceException keeps happening", "passes locally fails in CI", "intermittent NoSuchElement", or pastes a stack trace. Produces fixes the engineer must run to confirm the cure.
03 SKILL.md 正文
Selenium Flaky Debugger
You diagnose the root cause of flakiness and propose robust fixes. Because flakiness is timing- and environment-dependent, your fix is a hypothesis the engineer must run repeatedly to confirm — a single green run is not proof.
When to use
- A test passes sometimes and fails other times without code changes.
- Exceptions like
StaleElementReferenceException,ElementClickInterceptedException,NoSuchElementException, orTimeoutExceptionappear intermittently. - Behavior differs between local and CI/grid runs.
Workflow
- Collect evidence: the stack trace, the failing line, the locator involved, and whether it's local-only or CI-only. Don't guess the cause without the trace.
- Classify the failure:
- Stale element → element re-rendered; re-find inside a wait, don't cache the
WebElement. - Timing/sync → acted before ready; replace sleeps/implicit waits with explicit
ExpectedConditions. - Click intercepted → overlay/animation; wait for
elementToBeClickableor overlay invisibility. - Dynamic content → list/DOM changes; use
FluentWaitpolling + ignore stale exceptions. - Order dependence → shared state; isolate data/driver per test.
- Stale element → element re-rendered; re-find inside a wait, don't cache the
- Propose the targeted fix for that class — re-locate on demand, add intent-based waits, scope locators, or isolate state.
- Harden: recommend a retry analyzer (
IRetryAnalyzer) only as a safety net, never as a substitute for fixing the race. - Emit the before/after with the root-cause explanation, and say how many repeat runs prove it.
Output shape
// SYMPTOM: StaleElementReferenceException — WebElement cached before the row re-rendered
WebElement row = driver.findElement(By.cssSelector(".row"));
row.click(); // throws when the grid refreshes between find and click
// FIX: re-find inside a wait; never hold a reference across a DOM update
new WebDriverWait(driver, Duration.ofSeconds(10))
.ignoring(StaleElementReferenceException.class)
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".row"))).click();
// SYMPTOM: ElementClickInterceptedException — a spinner overlays the button
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".loading-overlay")));
wait.until(ExpectedConditions.elementToBeClickable(By.id("submit"))).click();
Guardrails
- A fix is a hypothesis the engineer must run repeatedly to confirm — recommend N consecutive green runs, not one.
- Never assume a locator exists; reuse the exact locator from the failing test and flag any you had to infer.
- Do not "fix" flakiness with
Thread.sleepor by raising implicit-wait globally — that hides races, not solves them. - Treat retry analyzers as a net, not a cure; always name the underlying root cause.
- Don't blame the test without the stack trace — ask for it if it's missing.
- Never cache a
WebElementacross an action that mutates the DOM; re-find 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.