A practical automation project that enhances Selenium-based testing with advanced debugging, cookie-powered login reuse, and a JSON-driven universal form filler β helping testers identify failures faster, eliminate login repetition, handle dynamic forms with ease, and keep secrets safe via .env.
This framework automates login functionality on the Automation Exercise site using:
-
Selenium WebDriver
-
TestNG
-
Allure Reporting
-
Smart logging with screenshots on failure
-
Cookie-based session reuse
-
.envsupport for credentials and secure environment variables -
Dynamic JSON-based Form Filling for any form, anywhere
Make sure the following are installed on your system:
-
Java 17+
-
Maven
-
Allure CLI
Run the following command to clean and execute your TestNG suite:
mvn clean test
After execution, you'll find:
-
πΈ Screenshots in
target/screenshots/ -
π§Ύ Test Logs in
target/test-output/test-log.txt -
π Allure Results in
target/allure-results/
To generate the Allure report:
allure serve target/allure-results
-
β Logs success, skip, and failure status of every test method.
-
πΈ Captures screenshots automatically on test failure.
-
π§Ύ Stores clear failure reasons (e.g., "Element not found") in the log file.
-
π Cookie-based login skip (load cookies if valid, re-login if expired).
-
π Uses
.envfile to load credentials securely. -
π§Ή Auto-clears old logs/screenshots per run.
-
π€ One Script to Fill Any Form Anywhere β powered by JSON + a dynamic
DataProvider.
- β
On the first login, session cookies are saved into a
cookies.jsonfile. - π On the next run:
- If cookies are still valid, they are reused to skip login entirely.
- If cookies are expired, a fresh login is triggered, and new cookies are saved.
π§ We use Gson for clean and structured cookie serialization & deserialization.
-
Separate methods for each form field become unnecessary.
-
All form input data is defined in a simple JSON file as key-value pairs mapping field names to values.
-
A universal DataProvider reads this JSON, automatically detects the input types (text, dropdown, file upload, checkbox, etc.), and fills the form accordingly.
-
Repetitive, hard-coded scripts are eliminated. Adding a new field requires only updating the JSON β no changes in code are necessary.
-
Integrated Allure reports combined with intelligent error handling ensure that any failures are logged clearly, simplifying debugging.
By combining JSON-driven data, a dynamic DataProvider, a universal form filler, and detailed Allure reports, tedious and repetitive form testing transforms into a smooth, adaptive, and highly maintainable automation system.
This is not just automation β it is automation with style.
Each test runs through a structured lifecycle for maximum clarity and minimal noise:
- π The browser is launched once at the suite start.
- π Each method logs its status (pass, fail, skip) in
test-log.txt. - πΈ On failure, a screenshot is captured, stored, and linked in the Allure report.
- π€ For forms, the JSON-driven dynamic filler automatically detects and fills the fields.
- β»οΈ All screenshots and logs are reset cleanly before every run in the
target/folder.
This setup makes it easier to:
- Identify bugs faster π
- Debug test failures with logs + visuals ππ·
- Integrate seamlessly into CI/CD pipelines βοΈ
- Avoid repetitive login steps = faster test cycles β‘
- Automate any form without extra code changes
Automated Login Validation on Automation Exercise:
- π§ Visit the login page
- π Enter valid credentials (loaded securely from
.env) - π― Validate successful login
- πͺ Save session cookies to
cookies.json - β‘ On the next run, reuse cookies to skip login (if still valid)
- π€ If a form is present, auto-fill it using JSON data without touching the code
Only relevant and necessary code is maintained for clarity and readability.
Read the full articles:
-
Test Smarter, Not Harder: Detailed Failure Debugging in Selenium
-
Cut Login Time, Boost Test Speed: Cookie-Powered QA Automation
-
The Ultimate Selenium Hack -- One Script to Fill Any Form, Anywhere
The test automation suite generates detailed Allure reports that provide clear insights into test execution, including step-by-step actions, screenshots on failure, and logs.
Below is an example screenshot from the Allure report:
