A Java Maven TestNG project for testing Selenium automation and LambdaTest Tunnel features. This project provides comprehensive form validation testing scenarios using Java, Maven, and TestNG.
- Java Maven TestNG: Modern Java testing framework with Maven dependency management
- Selenium WebDriver: Automated browser testing with Chrome headless support
- WebDriverManager: Automatic ChromeDriver management
- Comprehensive Test Suite: 13 test scenarios covering all validation cases
- TestNG Integration: Advanced test configuration and reporting
- CI/CD Ready: Headless browser support for continuous integration
- Java 11 or higher
- Maven 3.6 or higher
- Node.js (version 14 or higher) - for running the website server
- Chrome browser (for Selenium WebDriver)
First, start the Node.js server from the original project:
# Navigate to the original project directory
cd /Users/matthewedwards/selenium-test-website
# Install dependencies (if not already done)
npm install
# Start the server
npm startThe website will be available at http://localhost:3000
# Navigate to the Java project directory
cd /Users/matthewedwards/selenium-test-website-java
# Run all tests
mvn test
# Run tests with verbose output
mvn test -Dtest=FormValidationTest
# Run specific test method
mvn test -Dtest=FormValidationTest#testValidFormSubmissionselenium-test-website-java/
├── pom.xml                          # Maven configuration
├── testng.xml                       # TestNG suite configuration
├── README.md                        # This file
├── .gitignore                       # Git ignore file
└── src/
    ├── main/java/
    │   └── com/selenium/utils/
    │       └── FormHelper.java      # Helper class for form interactions
    └── test/java/
        └── com/selenium/tests/
            ├── BaseTest.java        # Base test class with setup/teardown
            └── FormValidationTest.java  # All test cases
The test suite includes comprehensive validation scenarios:
- ✅ Valid form submission → Success page
- ✅ Empty form submission → All error messages
- ✅ Invalid email format → Email error
- ✅ Invalid phone format → Phone error
- ✅ Short message → Message error
- ✅ Short name → Name error
- ✅ Clear button functionality → Form reset
- ✅ Multiple validation errors → Multiple error messages
- ✅ Valid phone formats → Various phone number formats
- ✅ Real-time validation → Field blur validation
- ✅ Form persistence → Data preserved on validation errors
- ✅ Success page elements → Success page verification
mvn testmvn test -Dtest=FormValidationTestmvn test -Dtest=FormValidationTest#testValidFormSubmission# Run only smoke tests
mvn test -Dgroups=smoke
# Run only validation tests
mvn test -Dgroups=validation# Run with visible browser (for debugging)
# Edit BaseTest.java and comment out: chromeOptions.addArguments("--headless");- Browser: Chrome (headless mode for CI/CD)
- Timeout: 10 seconds for element waits
- Base URL: http://localhost:3000
- Test Framework: TestNG
- Parallel Execution: 2 threads
The tests use the same element selectors as the Python version:
- Name field: #name-input
- Email field: #email-input
- Phone field: #phone-input
- Message field: #message-input
- Submit button: #submit-btn
- Clear button: #clear-btn
- Error messages: #name-error,#email-error,#phone-error,#message-error
The testng.xml file provides:
- Test Groups: smoke, validation, functionality
- Parallel Execution: Methods run in parallel with 2 threads
- Reporters: XML and JUnit report generation
- Test Order: Preserves test execution order
- Selenium WebDriver 4.15.2: Browser automation
- TestNG 7.8.0: Testing framework
- WebDriverManager 5.6.2: Automatic driver management
- Maven Surefire Plugin 3.2.2: Test execution
- ChromeDriver issues: WebDriverManager automatically downloads ChromeDriver
- Port conflicts: Ensure the website is running on port 3000
- Headless mode: Tests run in headless mode by default; remove --headlessfromBaseTest.javafor visual debugging
- Java version: Ensure Java 11+ is installed and configured
Enable visible browser for debugging:
- Edit BaseTest.java
- Comment out: chromeOptions.addArguments("--headless");
- Run tests to see browser interactions
TestNG generates reports in:
- target/surefire-reports/- Surefire reports
- target/testng-results/- TestNG reports
- 
Install LambdaTest CLI: npm install -g @lambdatest/cli 
- 
Set up tunnel: lt tunnel --port 3000 
- 
Update BaseTest.javato use tunnel URL instead of localhost
- Create new test methods in FormValidationTest.java
- Use @Testannotation with description
- Add to testng.xmlif needed
- Follow existing patterns for assertions
- Base URL: Modify baseUrlinBaseTest.java
- Timeouts: Adjust Duration.ofSeconds(10)inBaseTest.java
- Browser Options: Modify ChromeOptionsinBaseTest.java
- Parallel Execution: Update testng.xml
MIT License - Feel free to use this for testing purposes.