Skip to content
/ using_SHAFT_Engine Public template

A Template Repository for using SHAFT_Engine

ShaftHQ/using_SHAFT_Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Practical Automation Template: Using SHAFT_Engine

A powerful, ready-to-use template for starting your end-to-end test automation with SHAFT_Engine.

Build Status SHAFT Engine GitHub Stars


Table of Contents


πŸš€ Project Overview and Motivation

This repository is a production-ready starter kit for SHAFT_Engine users, eliminating setup overhead and providing hands-on experience with core featuresβ€”including Web, Mobile, API, and Database testing. SHAFT_Engine empowers engineers to write highly readable code, benefit from built-in reporting and logging, and leverage a unified API across multiple testing technologies.

Why Choose SHAFT_Engine?

  • πŸ”§ Unified API for Web, Mobile, API, and Database testing
  • πŸ“Š Built-in reporting with Allure integration and detailed logs
  • πŸ“– Highly readable and maintainable test code
  • ⚑ Zero configuration - works out of the box
  • 🌐 Cross-browser support with Selenium Grid integration
  • πŸ“ˆ CI/CD ready with GitHub Actions workflow included

Real-World Impact:

  • Reduce test automation setup time from days to minutes
  • Write maintainable tests that serve as living documentation
  • Scale across multiple browsers and environments effortlessly

⚑ Getting Started (Prerequisites and Dependencies)

Prerequisites

  • Java Development Kit (JDK) 21+ (recommended JDK 24 for latest features)
  • Apache Maven 3.6.3+
  • Modern IDE (e.g., IntelliJ IDEA, Eclipse, VS Code with Java extensions)
  • Docker (optional, for Selenium Grid testing)

Quick Installation

  1. Clone the repository:

    git clone https://github.com/ShaftHQ/using_SHAFT_Engine.git
    cd using_SHAFT_Engine
  2. Build the project:

    mvn clean compile
  3. Install dependencies:

    mvn clean install -DskipTests
  4. Verify installation:

    mvn test -Dtest=TestClass#navigateToDuckDuckGoAndAssertBrowserTitleIsDisplayedCorrectly

IDE Setup (IntelliJ IDEA Recommended)

  1. Import the project as a Maven project
  2. Ensure the Project SDK is set to JDK 21+

πŸ“ Project Structure Breakdown

using_SHAFT_Engine/
β”œβ”€β”€ πŸ“„ pom.xml                                    # Maven build configuration
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ main/
β”‚   β”‚   └── πŸ“ resources/
β”‚   β”‚       └── πŸ“ properties/                    # πŸ”§ Configuration hub
β”‚   β”‚           β”œβ”€β”€ πŸ“„ custom.properties          # Custom configurations
β”‚   β”‚           β”œβ”€β”€ πŸ“„ log4j2.properties          # Logging configuration
β”‚   β”‚           β”œβ”€β”€ πŸ“„ TestNG.properties          # TestNG runner settings
β”‚   β”‚           β”œβ”€β”€ πŸ“„ cucumber.properties        # Cucumber integration
β”‚   β”‚           β”œβ”€β”€ πŸ“„ reportportal.properties    # ReportPortal integration
β”‚   β”‚           └── πŸ“ default/                   # Default configuration fallbacks
β”‚   └── πŸ“ test/
β”‚       β”œβ”€β”€ πŸ“ java/
β”‚       β”‚   └── πŸ“ testPackage/
β”‚       β”‚       └── πŸ“„ TestClass.java            # πŸ§ͺ Sample test implementation
β”‚       └── πŸ“ resources/
β”‚           β”œβ”€β”€ πŸ“ testDataFiles/                # πŸ“Š Test data storage
β”‚           β”‚   └── πŸ“„ simpleJSON.json          # JSON test data
β”‚           └── πŸ“ META-INF/
β”‚               └── πŸ“ services/                 # Service configurations for listeners
β”œβ”€β”€ πŸ“ .github/
β”‚   └── πŸ“ workflows/
β”‚       β”œβ”€β”€ πŸ“„ e2etests.yml                     # πŸš€ CI/CD pipeline configuration
β”‚       └── πŸ“„ sync-template.yml                # πŸ”„ Automated template sync
└── πŸ“ target/                                   # πŸ“ˆ Generated reports and artifacts
    β”œβ”€β”€ πŸ“ logs/                                # Detailed execution logs
    β”œβ”€β”€ πŸ“ surefire-reports/                   # TestNG/JUnit reports
    └── πŸ“„ allure-report/                      # Rich HTML reports

Key Components Explained

Component Purpose Impact
pom.xml Dependencies, plugins, and build profiles Central project configuration
TestClass.java Sample web automation tests using SHAFT_Engine API Living documentation of framework capabilities
properties/ Runtime configurations for different environments Zero-code environment switching
testDataFiles/ External test data (JSON, CSV, Excel) Data-driven testing support
e2etests.yml Multi-browser CI/CD pipeline Automated testing across Chrome, Firefox, Edge
sync-template.yml Automated template synchronization Keeps repository files in sync with template

🎯 Usage and Running Tests

Sample Test Code Walkthrough

Here's the actual test code included in this template:

package testPackage;

import com.shaft.driver.SHAFT;
import com.shaft.gui.internal.locator.Locator;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.testng.annotations.*;

public class TestClass {
    SHAFT.GUI.WebDriver driver;
    SHAFT.TestData.JSON testData;

    String targetUrl = "https://duckduckgo.com/";

    // SHAFT's fluent locator API - more readable than traditional By locators
    By logo = By.xpath("//div[contains(@class,'container_fullWidth__1H_L8')]//img");
    By searchBox = Locator.hasAnyTagName().hasAttribute("name", "q").build();
    By firstSearchResult = Locator.hasTagName("article").isFirst().build();

    @Test
    public void navigateToDuckDuckGoAndAssertBrowserTitleIsDisplayedCorrectly() {
        // Fluent API with built-in reporting and error handling
        driver.browser().navigateToURL(targetUrl)
                .and().assertThat().title().contains(testData.getTestData("expectedTitle"));
    }

    @Test
    public void navigateToDuckDuckGoAndAssertLogoIsDisplayedCorrectly() {
        // Visual regression testing built-in
        driver.browser().navigateToURL(targetUrl)
                .and().element().assertThat(logo).matchesReferenceImage();
    }

    @Test
    public void searchForQueryAndAssert() {
        // Data-driven testing with JSON files
        driver.browser().navigateToURL(targetUrl)
                .and().element().type(searchBox, testData.getTestData("searchQuery") + Keys.ENTER)
                .and().assertThat(firstSearchResult).text()
                .doesNotEqual(testData.getTestData("unexpectedInFirstResult"));
    }

    @BeforeClass
    public void beforeClass() {
        // Load test data from JSON file
        testData = new SHAFT.TestData.JSON("simpleJSON.json");
    }

    @BeforeMethod
    public void beforeMethod() {
        // Create new driver instance for each test
        driver = new SHAFT.GUI.WebDriver();
    }

    @AfterMethod
    public void afterMethod() {
        // Automatic cleanup
        driver.quit();
    }
}

Running Tests - Multiple Options

1. Basic Test Execution

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=TestClass

# Run specific test method
mvn test -Dtest=TestClass#navigateToDuckDuckGoAndAssertBrowserTitleIsDisplayedCorrectly

2. Multi-Browser Testing (Local)

# Chrome (default)
mvn test -DtargetBrowserName=chrome

# Firefox
mvn test -DtargetBrowserName=firefox

# Microsoft Edge
mvn test -DtargetBrowserName=edge

# Headless execution
mvn test -DheadlessExecution=true

3. Selenium Grid / Docker Integration

# Download and start Selenium Grid
curl -o docker-compose.yml https://raw.githubusercontent.com/SeleniumHQ/docker-selenium/trunk/docker-compose-v3.yml
docker compose up --scale chrome=2 --scale firefox=2 -d

# Run tests against Grid
mvn test -DexecutionAddress=localhost:4444 -DtargetBrowserName=chrome

4. Advanced Configuration Options

# Parallel execution with custom threads
mvn test -DsetParallel=METHODS -DsetParallelMode=DYNAMIC -DthreadCount=3

# Generate Allure reports
mvn test -DgenerateAllureReportArchive=true

# Retry failed tests
mvn test -DretryMaximumNumberOfAttempts=2

# Custom test data environment
mvn test -DtestDataFolderPath=src/test/resources/testDataFiles/

Test Data Management

The template includes a JSON-based test data system:

{
  "searchQuery": "SHAFT_Engine",
  "expectedTitle": "DuckDuckGo", 
  "unexpectedInFirstResult": "Nope"
}

Accessing test data in your tests:

// In @BeforeClass
testData = new SHAFT.TestData.JSON("simpleJSON.json");

// In test methods
String query = testData.getTestData("searchQuery");

πŸ“Έ Visual Demonstration

🎬 Live Test Execution Demo

Coming Soon: Dynamic GIF showing a complete test run from execution to final HTML report generation.

πŸ“Š Rich HTML Reports

SHAFT_Engine generates comprehensive reports automatically:

  • Allure Reports: Interactive HTML reports with step-by-step screenshots
  • TestNG Reports: Detailed execution summaries
  • Custom Logs: Structured logging with different levels
  • Screenshots: Automatic capture on failures and assertions

πŸ”„ CI/CD Pipeline Visualization

The included GitHub Actions workflow provides:

  • βœ… Multi-browser testing (Chrome, Firefox, Edge)
  • 🐳 Dockerized Selenium Grid
  • πŸ“ˆ Automatic report generation and archiving
  • πŸ”„ Parallel execution across browser matrix
  • πŸ“Š Test summaries and artifact uploads

πŸ†˜ Support and Documentation

Official Resources

Quick Support Guide

Before Opening an Issue:

  1. Check existing issues
  2. Review the documentation
  3. Try the troubleshooting guide

When Opening an Issue, Include:

  • SHAFT_Engine version (mvn dependency:tree | grep SHAFT)
  • Java version (java -version)
  • Operating System and Browser versions
  • Complete error stack trace
  • Minimal reproducible test case

Learning Path

  1. Start Here: Run the sample tests in this template
  2. Next: Explore the Getting Started Guide
  3. Advanced: Check out Best Practices
  4. Expert: Contribute to the SHAFT_Engine Core

🀝 Contributing and License

How to Contribute

We welcome contributions from the community! Here's how you can help:

🌟 Ways to Contribute

  • πŸ› Report Bugs: Found something broken? Open an issue
  • πŸ’‘ Suggest Features: Have ideas for improvements? Start a discussion
  • πŸ“ Improve Documentation: Fix typos, add examples, or write guides
  • πŸ§ͺ Add Tests: Expand the test coverage with new examples
  • πŸ”§ Code Contributions: Implement new features or fix bugs

πŸš€ Quick Contribution Guide

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“‹ Contribution Guidelines

  • Follow existing code style and conventions
  • Add tests for new functionality
  • Update documentation for any API changes
  • Ensure all tests pass before submitting
  • Write clear commit messages

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License - Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files...

πŸ™ Acknowledgments

  • SHAFT_Engine Team for creating this amazing framework
  • Contributors who help improve this template
  • Community members who provide feedback and support

Ready to revolutionize your test automation?

⭐ Star this repository β€’ 🍴 Fork and customize β€’ πŸ“– Read the docs

Built with ❀️ by the SHAFT_Engine community

About

A Template Repository for using SHAFT_Engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages