Skip to content

Laserwolve-Games/CAFfeine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CAFfiene Logo

Java Selenium Maven

A comprehensive automation and testing framework built with Selenium WebDriver and Java, specifically designed for testing Construct applications and projects. This framework provides a robust foundation for automated testing with WebDriverManager for browser management and Logback for logging.

πŸš€ Features

  • Selenium WebDriver 4.32.0 - Latest Selenium features and improvements
  • WebDriverManager 6.1.0 - Automatic browser driver management
  • Logback Logging - Comprehensive logging with configurable levels
  • JUnit 5 Integration - Modern testing framework support
  • Cross-Browser Testing - Support for Chrome, Edge, and other browsers
  • Construct-Specific Methods - Specialized methods for testing Construct applications
  • Page Object Model - Organized XPath management and element handling
  • Utility Methods - Rich set of helper methods for common test operations

πŸ“‹ Prerequisites

  • Java 8+ - Java Development Kit
  • Maven 3.6+ - Build and dependency management
  • Supported Browsers - Chrome, Edge, Firefox (drivers managed automatically)

πŸ› οΈ Installation

  1. Clone the repository:

    git clone https://github.com/Laserwolve-Games/ConstructAutomationFramework.git
    cd ConstructAutomationFramework
  2. Install dependencies:

    mvn clean install
  3. Verify installation:

    mvn test

πŸ“ Project Structure

ConstructAutomationFramework/
β”œβ”€β”€ src/
β”‚   └── constructAutomation/
β”‚       β”œβ”€β”€ DaggerQuestTest.java    # Sample test implementation
β”‚       β”œβ”€β”€ Methods.java            # Core automation methods
β”‚       β”œβ”€β”€ Position.java           # Position utilities
β”‚       └── Xpaths.java            # XPath repository
β”œβ”€β”€ resources/
β”‚   └── logback.xml                # Logging configuration
β”œβ”€β”€ images/
β”‚   └── caffienelogo.png           # Project assets
β”œβ”€β”€ pom.xml                        # Maven configuration
└── README.md                      # This file

πŸ”§ Configuration

Logback Configuration

The framework uses Logback for logging. Configure logging levels in resources/logback.xml:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n</pattern>
        </encoder>
    </appender>
    <root level="error">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

Browser Configuration

WebDriverManager automatically handles browser driver downloads and management. No manual driver setup required!

πŸ§ͺ Writing Tests

Basic Test Structure

package constructAutomation;

import org.junit.jupiter.api.Test;

class MyConstructTest extends Methods {

    @Test
    void testConstructApplication() {
        // Start the desktop client
        startDesktopClient();
        
        // Perform test actions
        click("playButton");
        
        // Verify results
        verifyTrue("Game started successfully", 
            (boolean) executeJavascript("return runtime.layout.getLayer('gameLayer').isVisible"));
        
        // Clean up
        quit();
    }
}

Available Methods

The Methods class provides numerous utility methods:

  • Browser Management:

    • startDesktopClient() - Initialize browser for Construct testing
    • quit() - Close browser and clean up resources
  • Element Interaction:

    • click(String xpath) - Click on elements
    • sendKeys(String xpath, String text) - Input text
    • verifyTrue(String message, boolean condition) - Assertions
  • JavaScript Execution:

    • executeJavascript(String script) - Execute JavaScript in browser context
  • Verification:

    • verifyThrows(String message, Class<T> exception, ThrowingRunnable runnable) - Exception testing

XPath Management

The Xpaths class organizes all selectors:

// Example usage
click(Xpaths.AccountDropdown.logIn);
click(Xpaths.Dialog.AnimationsEditor.Animations.addAnimation);

πŸƒβ€β™‚οΈ Running Tests

Maven Commands

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=DaggerQuestTest

# Clean and rebuild
mvn clean install

# Run tests with specific profile
mvn test -Dspring.profiles.active=test

VS Code Tasks

The project includes pre-configured VS Code tasks:

  • Maven Build: Ctrl+Shift+P β†’ "Tasks: Run Task" β†’ "Maven Build"
  • Maven Test: Ctrl+Shift+P β†’ "Tasks: Run Task" β†’ "Maven Test"

πŸ“Š Test Results and Reports

Test results are automatically generated and can be found in:

  • target/surefire-reports/ - JUnit test reports
  • Console output with timestamps and log levels

πŸ” Debugging

Logging Levels

Adjust logging levels in logback.xml:

  • trace - Very detailed debugging
  • debug - General debugging information
  • info - General information
  • warn - Warning messages
  • error - Error messages only (default)

πŸ“ Best Practices

  • Page Object Model: Keep XPaths organized in Xpaths.java
  • Method Reusability: Use methods from Methods.java for common operations
  • Clear Test Names: Use descriptive test method names
  • Assertions: Always include meaningful assertion messages
  • Clean Up: Always call quit() in test teardown

πŸ›‘οΈ Dependencies

Dependency Version Purpose
Selenium Java 4.32.0 Web automation framework
WebDriverManager 6.1.0 Automatic driver management
Logback Classic 1.5.18 Logging framework
JUnit Jupiter Latest Testing framework

πŸ“„ License

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

Sponsor this project