This project demonstrates browser-based UI testing using Java, Cucumber, and Selenium WebDriver for a practice login website: https://practicetestautomation.com/practice-test-login/. It provides a clean, modular test framework for both Chrome and Firefox browsers using WebDriverManager.
-
Page Object Model (POM)
The project uses the Page Object Model to encapsulate page-specific logic and elements. This makes the test code more maintainable and scalable as the application grows. -
Reusable Step Definitions
Common login flows, assertions, and browser interactions are shared across scenarios to avoid duplication and promote modularity. -
Multi-Browser Support via Tags
By using Cucumber tags (@Chrome
and@Firefox
), tests can be easily executed against different browsers with minimal setup. -
Clean Assertions with Messages
Assertions include descriptive messages to make debugging easier when a test fails.
-
Clone the repository:
git clone https://github.com/linkenmin/practicetestautomation-demo.git
-
Install dependencies:
Ensure that you have Maven and Java installed.
mvn install
-
Run all tests:
This will run all login test scenarios for both browsers.
mvn test
-
Run tests by tag:
-
Only run tests in Chrome:
mvn test -Dcucumber.filter.tags="@Chrome"
-
Only run negative test cases:
mvn test -Dcucumber.filter.tags="@NegativeTest"
-
This project includes a Dockerfile
to easily build and run your tests inside a lightweight Docker container. It uses a multi-stage build based on Maven 3.8.4 with OpenJDK 17 (slim variant).
If you're building on an ARM64-based machine (like Apple Silicon), it's recommended to use buildx
with the --platform=linux/amd64
option to create an AMD64-compatible image:
docker buildx build --platform=linux/amd64 ...
This ensures the final image is not only significantly smaller in size, but also compatible with cloud CI/CD environments like AWS CodeBuild, which often expect AMD64 images by default.
If you're already on an AMD64 machine, you can build the image directly without using buildx
.
src/
├── main/ # Typically for production code, but this project focuses on tests
└── test/
└── java/
├── features/
│ ├── chrome.feature # Login tests for Chrome (positive + negative)
│ └── firefox.feature # Login tests for Firefox (positive + negative)
├── pages/
│ ├── LoginPage.java # Page object for login page
│ └── SecurePage.java # Page object for secure area after login
├── runners/
│ └── TestRunner.java # Cucumber test runner class
├── steps/
│ └── CommonSteps.java # Step definitions shared across scenarios
└── utils/
├── ChromeUtils.java # ChromeDriver setup
└── FirefoxUtils.java # FirefoxDriver setup