A comprehensive Selenium Java test automation framework with AI-powered failure analysis using local embeddings - no data leaves your machine!
Author: Pramod Dutta
Website: The Testing Academy
- Features
- Architecture
- Prerequisites
- Quick Start
- Project Structure
- Step-by-Step Setup
- Running Tests
- AI Analysis Dashboard
- How AI Similarity Search Works
- Configuration
- API Reference
- Contributing
- β Page Object Model (POM) - Clean separation of test logic and page elements
- β Selenium 4.27 - Latest Selenium with built-in WebDriver Manager
- β TestNG - Powerful test framework with parallel execution support
- β Allure Reporting - Beautiful test reports with screenshots on failure
- β Automatic Screenshots - Captures screenshots, page source, and URL on test failure
- β Structured Logging - JSONL format logs for AI analysis
- βοΈ BrowserStack Integration - Run tests on 3000+ real browsers and devices
- βοΈ LambdaTest Integration - Scalable cross-browser testing in the cloud
- π₯οΈ Local Execution - Run tests locally with Chrome, Firefox, or Edge
- π Easy Switching - Switch between local/cloud with a single parameter
- π§ Jenkins Pipeline - Ready-to-use Jenkinsfile with all stages
- π¦ Parameterized Builds - Configure browser, environment, and test suite
- π Allure Reports in Jenkins - Integrated reporting with trend analysis
- π€ AI Report Generation - Automatic AI analysis report in CI pipeline
- π§ Local AI Embeddings - Sentence-Transformers running 100% locally
- π Semantic Similarity Search - Find similar failures by meaning, not just keywords
- π Interactive Dashboard - Streamlit-based UI for visualizing test results
- π Privacy First - No data leaves your machine, no external API calls
- π Analytics - Track failure patterns, test duration, and trends
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TEST AUTOMATION FRAMEWORK β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Test Cases βββββΆβ Page Objects βββββΆβ Selenium β β
β β (TestNG) β β (POM) β β WebDriver β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Allure β β JSONL β β Screenshots β β
β β Reports β β Logs β β on Failure β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β
βββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI ANALYSIS PIPELINE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Log Parser βββββΆβ Embeddings βββββΆβ Qdrant β β
β β (Python) β β (Local AI) β β Vector Store β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββ β
β β Streamlit Dashboard β β
β β - Metrics & Charts β β
β β - Failure Analysis β β
β β - Similarity Search β β
β ββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Requirement | Version | Purpose |
|---|---|---|
| Java JDK | 17+ | Running Selenium tests |
| Maven | 3.8+ | Build and dependency management |
| Python | 3.9+ | AI analysis pipeline |
| Chrome/Firefox | Latest | Browser for testing |
# 1. Clone the repository
git clone https://github.com/pramods12/AIATBSeleniumJavaFramework.git
cd AIATBSeleniumJavaFramework
# 2. Install Java (macOS)
brew install openjdk@17
# 3. Run tests
./mvnw clean test
# 4. View Allure report
./mvnw allure:serve
# 5. Setup AI Analysis
cd ai-analysis
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 6. Launch Dashboard
streamlit run dashboard.pyAIATBSeleniumJavaFramework/
βββ π pom.xml # Maven configuration
βββ π testng.xml # TestNG suite configuration
βββ π mvnw # Maven wrapper
β
βββ π src/
β βββ π main/java/com/automation/
β β βββ π pages/ # Page Object classes
β β β βββ BasePage.java
β β β βββ LoginPage.java
β β β βββ DashboardPage.java
β β βββ π listeners/ # TestNG listeners
β β β βββ AllureScreenshotListener.java
β β βββ π analytics/ # Test analytics
β β βββ TestAnalyticsLogger.java
β β
β βββ π test/java/com/automation/
β βββ π base/ # Base test class
β β βββ BaseTest.java
β βββ π tests/ # Test classes
β βββ LoginTest.java
β
βββ π ai-analysis/ # AI Analysis Pipeline
β βββ π requirements.txt # Python dependencies
β βββ π dashboard.py # Streamlit dashboard
β βββ π main.py # CLI entry point
β βββ π config/
β β βββ settings.py # Configuration
β βββ π src/
β βββ log_parser.py # JSONL log parser
β βββ embedding_service.py # Local AI embeddings
β βββ vector_store.py # Qdrant vector database
β βββ analysis_service.py # Analysis orchestration
β βββ api.py # FastAPI REST API
β
βββ π target/ # Build output
βββ π allure-results/ # Allure report data
βββ π analytics-logs/ # JSONL test logs
βββ test-events.jsonl
macOS (Homebrew):
brew install openjdk@17
echo 'export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
java -versionUbuntu/Debian:
sudo apt update
sudo apt install openjdk-17-jdk
java -versionWindows:
- Download from Adoptium
- Run installer
- Add to PATH
# Clone repository
git clone https://github.com/yourusername/AIATBSeleniumJavaFramework.git
cd AIATBSeleniumJavaFramework
# Make Maven wrapper executable
chmod +x mvnw
# Build project (downloads dependencies)
./mvnw clean compile# Run all tests locally
./mvnw clean test
# Run specific test class
./mvnw test -Dtest=LoginTest
# Run with specific browser
./mvnw test -Dbrowser=firefox
# Run in headless mode (for CI)
./mvnw test -Dheadless=true# Set credentials (or use .env file)
export BROWSERSTACK_USERNAME=your_username
export BROWSERSTACK_ACCESS_KEY=your_access_key
# Run tests on BrowserStack
./mvnw test -Dexecution.env=browserstack -Dbrowser=chrome# Set credentials (or use .env file)
export LAMBDATEST_USERNAME=your_username
export LAMBDATEST_ACCESS_KEY=your_access_key
# Run tests on LambdaTest
./mvnw test -Dexecution.env=lambdatest -Dbrowser=chrome# Generate and open Allure report
./mvnw allure:serveThis opens a beautiful HTML report showing:
- β Test results with pass/fail status
- πΈ Screenshots on failure
- π Page source on failure
- π URLs where tests failed
# Navigate to AI analysis directory
cd ai-analysis
# Create Python virtual environment
python3 -m venv venv
# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
.\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# First run downloads the AI model (~90MB, one-time)# Make sure you're in ai-analysis directory with venv activated
cd ai-analysis
source venv/bin/activate
# Launch Streamlit dashboard
streamlit run dashboard.py --server.port 8501Open http://localhost:8501 in your browser.
# Start API server
python main.py serve
# Index test logs
curl -X POST http://localhost:8000/api/v1/index
# Get summary
curl http://localhost:8000/api/v1/summary
# Find similar failures
curl -X POST http://localhost:8000/api/v1/similar \
-H "Content-Type: application/json" \
-d '{"error_message": "Element not found"}'# Run all tests
./mvnw clean test
# Run with Allure report generation
./mvnw clean test allure:serve
# Run specific test class
./mvnw test -Dtest=LoginTest
# Run specific test method
./mvnw test -Dtest=LoginTest#testSuccessfulLogin
# Run tests in parallel (configured in testng.xml)
./mvnw test -Dparallel=methods -DthreadCount=4| Output | Location | Description |
|---|---|---|
| Test Results | target/surefire-reports/ |
TestNG XML reports |
| Allure Data | target/allure-results/ |
Allure report data |
| Analytics Logs | target/analytics-logs/test-events.jsonl |
JSONL for AI analysis |
| Screenshots | target/allure-results/*.png |
Failure screenshots |
| Page | Description |
|---|---|
| π Dashboard | Overview with pass/fail metrics, pie charts, duration analysis |
| π Test Events | Full list of all test events with filters and CSV export |
| π΄ Failures | Detailed failure view with error messages and stacktraces |
| π Similar Search | AI-powered semantic search for similar past failures |
| π Analytics | Timeline visualization, failures by class, duration statistics |
The dashboard provides:
- Real-time test metrics
- Interactive charts (Plotly)
- Semantic similarity search
- CSV export functionality
- Failure pattern analysis
Traditional Keyword Search:
"Connection timeout" β "Network unavailable" β No match!
AI Embedding Search:
"Connection timeout" β "Network unavailable" β
85% similar!
- Text β Vector: Error messages are converted to 384-dimensional vectors
- Semantic Meaning: Similar meanings = similar vectors
- Cosine Similarity: Find closest matches in vector space
Error Message β Vector (384 numbers)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"Element not found: login button" β [0.23, -0.15, 0.87, ...]
"Could not locate login button" β [0.21, -0.14, 0.85, ...] β 92% Similar!
"Database connection failed" β [-0.45, 0.32, 0.11, ...] β Different
| Component | Location | Data Sharing |
|---|---|---|
| Sentence-Transformers | Local CPU | Model downloaded once, runs offline |
| Qdrant Vector DB | In-memory | Data stays in RAM |
| Dashboard | localhost | Never exposed externally |
No data leaves your machine!
testng.xml - Test suite configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Automation Test Suite" parallel="methods" thread-count="2">
<listeners>
<listener class-name="io.qameta.allure.testng.AllureTestNg"/>
<listener class-name="com.automation.listeners.AllureScreenshotListener"/>
</listeners>
<test name="Login Tests">
<classes>
<class name="com.automation.tests.LoginTest"/>
</classes>
</test>
</suite>ai-analysis/config/settings.py:
# Paths
LOGS_PATH = "../target/analytics-logs/test-events.jsonl"
# Embedding Model (runs locally)
EMBEDDING_MODEL = "all-MiniLM-L6-v2" # 384 dimensions
EMBEDDING_DIMENSION = 384
# Vector Store
QDRANT_COLLECTION = "test_failures"
SIMILARITY_THRESHOLD = 0.3 # Minimum similarity scoreBase URL: http://localhost:8000
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/api/v1/health |
GET | Detailed health status |
/api/v1/index |
POST | Load and index test logs |
/api/v1/summary |
GET | Get failure summary |
/api/v1/similar |
POST | Find similar failures |
/api/v1/analyze |
POST | Analyze specific failure |
# Health check
curl http://localhost:8000/
# Index logs
curl -X POST http://localhost:8000/api/v1/index
# Get summary
curl http://localhost:8000/api/v1/summary
# Find similar failures
curl -X POST http://localhost:8000/api/v1/similar \
-H "Content-Type: application/json" \
-d '{
"error_message": "Element not found: login button",
"top_k": 5
}'Index Response:
{
"status": "success",
"total_events": 10,
"failures_indexed": 1,
"passed": 4,
"failed": 1
}Similar Failures Response:
[
{
"score": 0.85,
"test_name": "testLoginButton",
"class_name": "LoginTest",
"message": "Element not found: signin-btn",
"timestamp": "2024-01-15T10:30:00Z"
}
]// src/main/java/com/automation/pages/NewPage.java
public class NewPage extends BasePage {
@FindBy(id = "element-id")
private WebElement myElement;
public NewPage(WebDriver driver) {
super(driver);
}
public void clickElement() {
click(myElement);
}
}// src/test/java/com/automation/tests/NewTest.java
public class NewTest extends BaseTest {
@Test
@Description("Test description for Allure")
public void testNewFeature() {
// Your test logic
}
}The included Jenkinsfile provides a complete CI/CD pipeline:
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Checkout βββββΆβ Build βββββΆβ Run Tests βββββΆβ Allure βββββΆβ AI Analysis β
β β β Compile β β (Params) β β Report β β Report β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
| Parameter | Options | Description |
|---|---|---|
BROWSER |
chrome, firefox, edge | Browser for test execution |
EXECUTION_ENV |
local, browserstack, lambdatest | Test execution environment |
TEST_SUITE |
testng.xml | TestNG suite file |
GENERATE_AI_REPORT |
true/false | Generate AI analysis report |
-
Install Required Plugins:
- Allure Jenkins Plugin
- Pipeline Plugin
- Credentials Plugin
-
Configure Credentials:
Jenkins β Manage Jenkins β Credentials β Add: - browserstack-username (Secret text) - browserstack-access-key (Secret text) - lambdatest-username (Secret text) - lambdatest-access-key (Secret text) -
Configure Tools:
Jenkins β Global Tool Configuration: - JDK17 (Java 17) - Maven3 (Maven 3.8+) -
Create Pipeline Job:
- New Item β Pipeline
- Pipeline β Definition: Pipeline script from SCM
- SCM: Git β Repository URL: your-repo-url
- Script Path: Jenkinsfile
# Trigger with default parameters
# Or use Jenkins UI to customize:
# - Browser: chrome/firefox/edge
# - Environment: local/browserstack/lambdatest
# - AI Report: enabled/disabled-
Get Credentials: https://www.browserstack.com/accounts/settings
-
Set Environment Variables:
export BROWSERSTACK_USERNAME=your_username export BROWSERSTACK_ACCESS_KEY=your_access_key
-
Run Tests:
./mvnw test -Dexecution.env=browserstack -Dbrowser=chrome -
View Results: https://automate.browserstack.com/dashboard
-
Get Credentials: https://accounts.lambdatest.com/detail/profile
-
Set Environment Variables:
export LAMBDATEST_USERNAME=your_username export LAMBDATEST_ACCESS_KEY=your_access_key
-
Run Tests:
./mvnw test -Dexecution.env=lambdatest -Dbrowser=firefox -
View Results: https://automation.lambdatest.com/timeline
Both platforms are configured with:
- Video recording of test execution
- Network logs capture
- Console logs capture
- Screenshot on failure
- Selenium 4.27 support
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Generate a standalone HTML report with charts and failure details:
cd ai-analysis
source venv/bin/activate
python report_generator.py -o test_report.htmlThis generates a beautiful report with:
- π Pass/fail metrics with charts
- π΄ Detailed failure cards with stacktraces
- β Passed test summary
- π§ AI analysis information
The context.yaml file contains all the information needed to recreate this project. Use it as:
- Reference - Understand the project structure and components
- AI Context - Provide to AI assistants to understand the project
- Documentation - Quick overview of all technologies and configurations
# Key sections in context.yaml:
project: # Project metadata
stack: # Technology versions (Java, Python, libraries)
structure: # File/folder organization
features: # Detailed feature descriptions
commands: # All CLI commands needed
test_site: # Test application detailsThis project is licensed under the MIT License - see the LICENSE file for details.
Pramod Dutta
- Website: The Testing Academy
- YouTube: The Testing Academy
- LinkedIn: Pramod Dutta
If you find this project useful, please consider giving it a star! β
Made with β€οΈ by The Testing Academy