This is a demo project that serves as a reference template for creating new test automation projects using Selenium WebDriver with TestNG.
├── 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
- Selenium WebDriver integration
- TestNG test framework
- Chrome browser automation
- Screenshot capture on test failure
- Logging implementation
- Gradle build system
- Cross-platform support
- JDK 11 or higher
- Gradle 7.x or higher
- Chrome browser
- Git
- Clone the repository:
git clone https://github.com/yourusername/AppScripAutomationAssignment.git
cd AppScripAutomationAssignment
-
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)
-
Build the project:
gradlew.bat clean build
- Run tests:
gradlew.bat test
Or
gradlew.bat clean test
- Clone the repository:
git clone https://github.com/yourusername/AppScripAutomationAssignment.git
cd AppScripAutomationAssignment
- Set JAVA_HOME environment variable:
export JAVA_HOME=/path/to/your/jdk
export PATH=$JAVA_HOME/bin:$PATH
- Make gradlew executable:
chmod +x gradlew
- Build the project:
./gradlew clean build
- Run tests:
./gradlew test
Or
gradlew.bat clean test
The project includes a sample test case (TestCase01.java) that:
- Opens Google search
- Searches for "Open AI"
- Verifies search results
- 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
- TestNG configuration:
src/test/resources/testng.xml
- Build configuration:
build.gradle
- Browser options:
DriverManager.java
- Page Object Model structure
- Centralized WebDriver management
- Test listeners for logging and screenshots
- Proper exception handling
- Gradle dependency management
- Cross-platform compatibility
- Fork this repository
- Modify package names and configurations
- Add your page objects
- Create your test cases
- Update testng.xml with your test classes
- This is a demo project intended as a reference
- Chrome browser is required
- Internet connection needed for dependencies
- Gradle will download required dependencies automatically