npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

selenium-flaky-detector

v1.1.0

Published

πŸ” Detect, score, and fix flaky Selenium/Java tests using entropy-based analysis, root-cause diagnosis, and a premium HTML dashboard.

Readme

πŸ” selenium-flaky-detector

Entropy-Based Flaky Test Detection for Selenium/Java Projects

Detect, score, and fix flaky Selenium tests with a premium interactive dashboard, root-cause analysis, and smart fix recommendations.

npm version License: MIT Node.js Java


🧠 What is Entropy-Based Detection?

A flaky test is a test that sometimes passes and sometimes fails without any code changes. This is extremely common in Selenium/Java due to async logic, variable network latency, and DOM rendering "race conditions."

Traditional testing tools just tell you: "Test A Failed". But if it failed 1 out of 3 times, how bad is the flakiness?

This detector handles that by using an Information Theory formula (Entropy) to calculate a true Flakiness Percentage rather than just giving you pass/fail states:

  • 0% Entropy (Total Order): Tests that Always Pass or Always Fail are predictable and get a 0% flaky score.
  • 100% Entropy (Maximum Chaos): A test that passes exactly 50% of the time is a true coin flip, destroying CI/CD trust, and scores 100%.

By focusing on entropy, we ignore "consistently broken" tests (which are just regular bugs) and surgically spotlight the truly chaotic timing and network issues.


⚑ Simplified Usage (The 3-Step Guide)

If you just want to get started immediately, follow these three simple steps:

1️⃣ Step 1: Install the Plugin

Open your terminal and install the tool globally so you can use it anywhere:

npm install -g selenium-flaky-detector

2️⃣ Step 2: Run the Command

Navigate to your Maven/Gradle project folder and trigger the detector:

# Recommended for development (runs 3 times)
npx selenium-flaky-detect --runs 3

3️⃣ Step 3: See the Reports

Once finished, an interactive HTML Dashboard will automatically pop up in your browser. Review your "Flakiness Score" and apply the smart fix recommendations!


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🎭  LAYER 1 Β· Orchestration                                         β”‚
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ Your Project │─────▢│ βš™οΈ  Orchestrator  │─────▢│ β˜•  Maven    β”‚  β”‚
β”‚   β”‚ (Maven/Gradle)β”‚      β”‚  Engine          β”‚      β”‚   Runner     β”‚  β”‚
β”‚   β”‚              β”‚      β”‚  Command         β”‚      β”‚ (Surefire)   β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ”  LAYER 2 Β· Test Execution Loop                                   β”‚
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ πŸ”’ Multi-Run  │─────▢│ πŸ“„ Surefire XML  │─────▢│ πŸ’₯ Failure   β”‚  β”‚
β”‚   β”‚   Manager    β”‚      β”‚  Aggregation     β”‚      β”‚   Capture    β”‚  β”‚
β”‚   β”‚ (N Repeats)  β”‚      β”‚  (JUnit XML)     β”‚      β”‚   Engine     β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🧠  LAYER 3 Β· Intelligence & Scoring                                β”‚
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ πŸ“Š Entropy    β”‚    β”‚ πŸ” Root Cause    β”‚    β”‚ πŸ’― Health Score  β”‚  β”‚
β”‚   β”‚   Scorer     β”‚    β”‚   Analyzer       β”‚    β”‚   Calculator     β”‚  β”‚
β”‚   β”‚  (0–100%)    β”‚    β”‚  (Auto-Diag)     β”‚    β”‚   (0–100)        β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ“‹  LAYER 4 Β· Actionable Reporting                                  β”‚
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ πŸ–₯️ Interactive│─────▢│ πŸ’‘ Fix Advice    │─────▢│ 🚦 CI Trust  β”‚  β”‚
β”‚   β”‚   Dashboard  β”‚      β”‚  (Smart RCA)     β”‚      β”‚   Gate       β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧩 Understanding the Layers

  • Layer 1: Orchestration. Handles the CLI orchestrator to launch your test suite. It manages the lifecycle of the Maven/Gradle runner.
  • Layer 2: Test Execution Loop. Executes your Selenium test suite multiple times (N repeats) to gather a reliable sample size. It continuously parses the generated Surefire XML reports, capturing every failure trace, error message, and test duration.
  • Layer 3: Intelligence & Scoring. The brain of the detector. The Entropy Scorer mathematically calculates a test's exact Flakiness Percentage (0–100%) and generates a global Suite Health Score. Next, the Root Cause Analyzer scans the failed Java stack traces, pattern-matching against known Selenium exceptions to categorize exactly why it failed (e.g., StaleElementReferenceException).
  • Layer 4: Actionable Reporting. Translates the raw data into an interactive HTML dashboard. Recommends specific, pattern-based Java/Selenium code fixes (e.g., β€œAdd explicit wait here”) based on the identified root cause. Optionally acts as a CI Trust Gate to aggressively block builds if flaky tests cross a configured threshold.

πŸš€ Step-by-Step Guide

1. Install the CLI Globally

To use the tool across any project on your machine, install it globally via npm:

npm install -g selenium-flaky-detector

2. Verify Installation

Ensure the CLI is installed correctly by checking the version or help menu:

selenium-flaky-detect --help

3. Prepare Your Java Project

The detector relies on Maven Surefire to generate XML test reports. You must ensure your pom.xml is configured to not fail the build immediately when a test fails, so all tests can finish.

Add this property to your maven-surefire-plugin configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.2.5</version>
  <configuration>
    <!-- Crucial: Let the build succeed even if tests fail -->
    <testFailureIgnore>true</testFailureIgnore>
  </configuration>
</plugin>

4. Run the Detector on Your Project

Navigate to your project's root directory (where the pom.xml lives) and run the npx command:

# Recommended for development (runs 3 times)
npx selenium-flaky-detect --runs 3

[!TIP] Choosing the right run count:

  • --runs 2: Quick sanity check after applying a fix.
  • --runs 3: (Default) Balanced speed and accuracy for local dev.
  • --runs 5+: Recommended for CI/CD to catch rare, elusive flakes.

If your terminal is somewhere else, you can provide the absolute path to your Java project:

npx selenium-flaky-detect --project /Users/mvsaran/my-java-app --runs 5

If you only want to analyze a specific subset of test classes (to save time):

npx selenium-flaky-detect --runs 3 --spec "LoginTest,CheckoutTest"

5. Review the Premium Report

Once all runs are complete, the tool will automatically open a highly interactive HTML dashboard in your default browser:

  • Identify tests with a Flakiness Score between 1% and 99%.
  • Analyze the automatically generated Root Cause (RCA) tags (e.g., Timeout, Stale Element).
  • Fix the tests using the recommended code suggestions provided for each specific RCA.

πŸ”„ 6. Fix, Re-Run, and Verify

This is the most important step! After you apply a fix to your Java files:

  1. Do NOT run mvn test directly (it will fail on the first error and stop).
  2. Instead, re-run the detector using npx: npx selenium-flaky-detect --runs 3.
  3. The tool will automatically handle the errors, finish the runs, and update your Health Score to show that the test is now 🟒 STABLE.

πŸ“¦ Installation

# Global CLI (recommended)
npm install -g selenium-flaky-detector

# Or use directly with npx (no install needed)
npx selenium-flaky-detect --help

Requirements:

  • Node.js β‰₯ 14
  • Java 17+
  • Maven or Gradle
  • Google Chrome + ChromeDriver (auto-managed by WebDriverManager)

βš™οΈ CLI Options

| Option | Default | Description | |---|---|---| | --runs <n> | 3 | Number of times to repeat the test suite | | --project <path> | . | Path to the Maven/Gradle project | | --output <path> | ./flaky-report | Output directory for the HTML report | | --spec <pattern> | (all) | Test class filter (e.g. *Login*) | | --threshold <n> | 70 | CI gate minimum health score (0–100) | | --no-open | (auto-open) | Skip auto-opening the HTML report | | --demo | β€” | Run the built-in ShopFlake Java demo |


🧩 Programmatic API

const { FlakyDetector } = require('selenium-flaky-detector');

const detector = new FlakyDetector({
  runs: 3,
  projectPath: './my-java-project',
  outputDir: './flaky-report',
  specPattern: '**/LoginTest*',
  ciThreshold: 80,
  openReport: true,
  buildTool: 'maven', // or 'gradle' β€” auto-detected by default
});

const result = await detector.run();

console.log(result.healthScore);    // 0–100
console.log(result.passed);         // true if healthScore >= threshold
console.log(result.scores);         // per-test flakiness scores
console.log(result.analysis);       // root cause analysis
console.log(result.reportPath);     // absolute path to HTML report

πŸ“Š Entropy-Based Flakiness Scoring

╔══════════════════════════════════════════════════╗
β•‘  Flakiness = 4 Γ— passRate Γ— (1 βˆ’ passRate) Γ— 100  β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

| Score | Meaning | Indicator | |---|---|---| | 0% | Stable β€” always passes OR always fails | 🟒 | | 1–49% | Mildly flaky | 🟑 | | 50–79% | Moderately flaky | 🟠 | | 80–99% | Severely flaky | πŸ”΄ | | 100% | Perfectly flaky β€” exact 50/50 split | πŸ’€ |


πŸ” Root Cause Analysis

The engine auto-classifies Selenium failures:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Selenium RCA Pattern Engine                                   β”‚
β”‚                                                                β”‚
β”‚  StaleElementReferenceException  ──▢  ♻️  Stale Element       β”‚
β”‚  TimeoutException                ──▢  ⏱️  Timeout             β”‚
β”‚  NoSuchElementException          ──▢  πŸ”  Missing Element      β”‚
β”‚  ElementNotInteractableException ──▢  πŸ‘οΈ  Element Not Ready   β”‚
β”‚  AssertionError / TestNG Assert  ──▢  ⚑  Async Load           β”‚
β”‚  SocketException / ConnectError  ──▢  🌐  Network / Connection β”‚
β”‚  WebDriverException              ──▢  πŸš—  WebDriver Instabilityβ”‚
β”‚  ConfigurationFailure            ──▢  πŸ”§  Config Failure      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Smart Fix Recommendations

♻️ Fix: StaleElementReferenceException

// ❌ Problem: Cached element goes stale after DOM update
WebElement btn = driver.findElement(By.id("submit"));
waitFor(someCondition);
btn.click();  // StaleElementReferenceException!

// βœ… Fix: Re-fetch element just before interaction
waitFor(someCondition);
driver.findElement(By.id("submit")).click();

⏱️ Fix: TimeoutException / Hard Waits

// ❌ Problem: Hard-coded sleep is fragile
Thread.sleep(3000);
driver.findElement(By.id("product-list")).click();

// βœ… Fix: Explicit wait for element to be clickable
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(By.id("product-list")));
el.click();

⚑ Fix: AssertionError on Async Count

// ❌ Problem: Count assertion before async load completes
List<WebElement> products = driver.findElements(By.className("product-card"));
assertEquals(12, products.size());

// βœ… Fix: Wait for expected count first
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
List<WebElement> products = wait.until(
    ExpectedConditions.numberOfElementsToBe(By.className("product-card"), 12)
);
assertEquals(12, products.size());

πŸ“ Project Structure

selenium-flaky-detector/
β”‚
β”œβ”€β”€ πŸ“¦ package.json               # npm configuration & CLI bin entry
β”œβ”€β”€ πŸš€ run-demo.js                # One-click demo orchestrator
β”‚
β”œβ”€β”€ bin/
β”‚   └── πŸ’» flaky-detect.js        # CLI entry point (global binary)
β”‚
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ πŸ“‹ index.js               # Public API β€” FlakyDetector class
β”‚   β”œβ”€β”€ βš™οΈ  orchestrator.js        # Layer 1: Demo lifecycle manager
β”‚   β”œβ”€β”€ πŸ”’ runner.js              # Layer 2: Multi-run Maven/Gradle executor
β”‚   β”œβ”€β”€ πŸ“„ parser.js              # Layer 2: Surefire XML report parser
β”‚   β”œβ”€β”€ πŸ“Š scorer.js              # Layer 3: Entropy scorer + health score
β”‚   β”œβ”€β”€ πŸ” analyzer.js            # Layer 3: Root cause analyzer (7 patterns)
β”‚   └── πŸ–₯️  reporter.js           # Layer 4: Premium HTML dashboard generator
β”‚
└── demo-app/                     # β˜• Java Spring Boot ShopFlake Demo
    β”œβ”€β”€ pom.xml                   # Maven config (Selenium 4, JUnit 5)
    └── src/
        β”œβ”€β”€ main/java/io/shopflake/
        β”‚   β”œβ”€β”€ ShopFlakeApplication.java   # Spring Boot entry point
        β”‚   └── controller/
        β”‚       β”œβ”€β”€ ShopController.java     # Page routes (/, /cart, /deals)
        β”‚       └── ApiController.java      # REST API (7 flakiness sources!)
        β”œβ”€β”€ main/resources/
        β”‚   β”œβ”€β”€ application.properties
        β”‚   └── templates/
        β”‚       β”œβ”€β”€ index.html              # πŸ›’ Product grid (flaky: async load)
        β”‚       β”œβ”€β”€ cart.html               # πŸ›’ Cart (flaky: 30% stale data)
        β”‚       └── deals.html              # ⚑ Deals (maximally flaky: 50/50)
        └── test/java/io/shopflake/tests/
            β”œβ”€β”€ ShopFlakeBaseTest.java       # Shared WebDriver setup
            β”œβ”€β”€ ProductLoadingTest.java      # 🟑 FLAKY: async timing
            β”œβ”€β”€ CartFunctionalityTest.java   # 🟠 FLAKY: race conditions
            β”œβ”€β”€ FlashDealsTest.java          # πŸ”΄ VERY FLAKY: 50/50
            β”œβ”€β”€ StableControlTest.java       # 🟒 STABLE: control group
            └── SearchAndSessionTest.java    # 🟑 MIXED: some flaky


πŸ“Š Report Features

╔══════════════════════════════════════════════════════════════════╗
β•‘  πŸ“‹  FLAKY TEST REPORT                           Health: 68/100  β•‘
╠══════════════════════════════════════════════════════════════════╣
β•‘  πŸ’―  Suite Health Score     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘  68 / 100         β•‘
β•‘  πŸ”₯  Pass/Fail Heatmap      [Run 1][Run 2][Run 3][Run 4][Run 5]  β•‘
β•‘  πŸ’‘  Precision Recommendations  7 recommendations found      β•‘
β•‘  🏷️  Root Cause Labels      ⏱Timeout Β· β™»Stale Β· βœ…Reliable   β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

| Feature | Description | |---|---| | πŸ’― Suite Health Score | Overall reliability index from 0–100 (animated ring) | | πŸ”₯ Pass/Fail Heatmap | Visual grid β€” βœ“/βœ— per test per run | | πŸ’‘ Precision Recommendations | Specific, actionable Java/Selenium fix snippets | | 🏷️ Root Cause Labels | Auto-tags: Timeout, Stale Element, Reliable Pass, etc. | | 🚦 CI Trust Gate | Hard pass/fail with configurable threshold |


πŸ€– CI/CD Integration

# GitHub Actions example
- name: Run Flaky Detection
  run: npx selenium-flaky-detect --runs 3 --threshold 75
  # Exits with code 1 if health score < 75 (blocks merge)
// package.json scripts
{
  "scripts": {
    "flaky:check": "selenium-flaky-detect --runs 3 --threshold 70"
  }
}

πŸ“„ Framework Configuration

The detector supports both JUnit 5 and TestNG projects via Maven Surefire or Gradle.

Maven (JUnit 5 / TestNG)

Ensure your pom.xml generates standard reports:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.2.5</version>
  <configuration>
    <!-- Never stop on failures β€” let detector analyze all results -->
    <testFailureIgnore>true</testFailureIgnore>
    <!-- JUnit XML report location (Automatically parsed) -->
    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
    
    <!-- TestNG Specific: If using testng.xml -->
    <!-- <suiteXmlFiles><suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile></suiteXmlFiles> -->
  </configuration>
</plugin>

TestNG results.xml (Native)

We also support parsing the native testng-results.xml file if your configuration generates it! Simply point the detector to the directory containing this file.



πŸ”§ Troubleshooting & Common Issues

❌ Error: "Requires a project to execute but there is no POM in this directory"

This happens when Maven cannot find your pom.xml file.

Resolution Steps:

  1. Check your path: Ensure you are running the command in the exact folder that contains pom.xml.
  2. Subdirectories: If your Java project is in a subfolder (e.g., eclipse-workspace/MyProject), you must point to that folder:
    npx selenium-flaky-detect --project "./MyProject" --runs 3
  3. Use Absolute Paths: If relative paths are failing, use the full path to the project:
    npx selenium-flaky-detect --project "C:\Users\Name\eclipse-workspace\TestNGFramework" --runs 3
  4. Confirm Build Tool: The tool auto-detects Maven (pom.xml) and Gradle (build.gradle). Ensure one of these files exists in the target directory.

⚠️ Error: "No XML reports found"

This usually means the tests didn't run at all or failed to generate reports.

Resolution Steps:

  1. Run manually first: Try running mvn test in your project folder to ensure Maven is installed and your tests are valid.
  2. Check target folder: Ensure Maven is generating XML files in target/surefire-reports.
  3. Check Plugin Config: Ensure testFailureIgnore is set to true in your pom.xml (see Step 3 in the Step-by-Step guide).

πŸ”— Links


πŸ“„ License

MIT Β© SeleniumFlaky Contributors