Skip to content

Code-Scratcher/AppScrip

Repository files navigation

Selenium TestNG Automation Framework Template

This is a demo project that serves as a reference template for creating new test automation projects using Selenium WebDriver with TestNG.

Project Structure

├── src
│   └── test
│       ├── java
│       │   └── com.example.selenium
│       │       ├── base
│       │       │   └── DriverManager.java    # WebDriver initialization and management
│       │       ├── listeners                 # TestNG listeners
│       │       │   ├── TestListener.java     # Test execution logging
│       │       │   └── ScreenshotListener.java # Screenshot capture on test events
│       │       ├── pages                     # Page Object Model classes
│       │       │   └── HomePage.java         # Google homepage elements and actions
│       │       ├── tests                     # Test cases
│       │       │   ├── TestCase01.java      # Google search test
│       │       │   └── TestCase02.java      # Example test
│       │       └── utilities                 # Utility classes
│       │           └── ScreenshotUtil.java   # Screenshot capture utility
│       └── resources
│           └── testng.xml                    # TestNG configuration
├── screenshots                               # Screenshot output directory
├── build.gradle                              # Gradle build configuration
└── README.md

Features

  • Selenium WebDriver integration
  • TestNG test framework
  • Chrome browser automation
  • Screenshot capture on test failure
  • Logging implementation
  • Gradle build system
  • Cross-platform support

Prerequisites

  • JDK 11 or higher
  • Gradle 7.x or higher
  • Chrome browser
  • Git

Setup Instructions

Windows

  1. Clone the repository:
git clone https://github.com/yourusername/AppScripAutomationAssignment.git
cd AppScripAutomationAssignment
  1. Set JAVA_HOME environment variable:

    • Right-click on 'This PC' > Properties > Advanced System Settings
    • Click 'Environment Variables'
    • Add new System Variable:
      • Variable name: JAVA_HOME
      • Variable value: Path to your JDK (e.g., C:\Program Files\Java\jdk-11)
  2. Build the project:

gradlew.bat clean build
  1. Run tests:
gradlew.bat test

Or

gradlew.bat clean test

Linux/macOS

  1. Clone the repository:
git clone https://github.com/yourusername/AppScripAutomationAssignment.git
cd AppScripAutomationAssignment
  1. Set JAVA_HOME environment variable:
export JAVA_HOME=/path/to/your/jdk
export PATH=$JAVA_HOME/bin:$PATH
  1. Make gradlew executable:
chmod +x gradlew
  1. Build the project:
./gradlew clean build
  1. Run tests:
./gradlew test

Or

gradlew.bat clean test

Test Execution

The project includes a sample test case (TestCase01.java) that:

  1. Opens Google search
  2. Searches for "Open AI"
  3. Verifies search results
  4. Captures screenshots

Test results and logs can be found in:

  • Test reports: build/reports/tests/test/index.html
  • Screenshots: build/screenshots/
  • Logs: Console output with SLF4J

Configuration

  • TestNG configuration: src/test/resources/testng.xml
  • Build configuration: build.gradle
  • Browser options: DriverManager.java

Best Practices Demonstrated

  • Page Object Model structure
  • Centralized WebDriver management
  • Test listeners for logging and screenshots
  • Proper exception handling
  • Gradle dependency management
  • Cross-platform compatibility

Using as Template

  1. Fork this repository
  2. Modify package names and configurations
  3. Add your page objects
  4. Create your test cases
  5. Update testng.xml with your test classes

Notes

  • This is a demo project intended as a reference
  • Chrome browser is required
  • Internet connection needed for dependencies
  • Gradle will download required dependencies automatically

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages