A Java-based test automation framework built for the Ejada Senior Automation Tester assignment, covering both UI and API testing.
| Layer | Tool |
|---|---|
| Language | Java 17 |
| UI Driver | Selenium WebDriver 4 |
| BDD | Cucumber (Gherkin) |
| Test Runner | TestNG |
| API Testing | RestAssured |
| Driver Mgmt | WebDriverManager (auto binary download) |
| Reporting | ExtentReports (Spark HTML) via Cucumber adapter |
| Build Tool | Maven |
src/test/java/com/ejada/automation/
├── api/ -> RestAssured API tests (Simple Books API)
├── base/ -> DriverFactory (thread-safe, cross-browser) + BasePage
├── pages/ -> Page Object Model classes (Login, Inventory, Cart, Checkout)
├── runners/ -> Cucumber-TestNG runner
├── stepdefinitions/ -> Step definitions + Hooks (driver lifecycle, screenshot on failure)
└── utils/ -> ConfigReader
src/test/resources/
├── features/ -> .feature files (Gherkin scenarios)
├── config.properties -> Base URLs, credentials, browser, timeouts
├── testng.xml -> Parallel cross-browser + API suite config
├── extent.properties -> ExtentReports adapter config
└── spark-config.xml -> Report theme/branding
UI (saucedemo.com)
- Login: valid login, invalid credentials, locked-out user, empty username/password (via Scenario Outline)
- Full order flow: add product to cart → checkout → fill shipping info → finish → verify confirmation
- Cross-browser: Chrome + Firefox, configured externally in
config.properties/ overridable via-Dbrowser= - Parallel execution: TestNG runs Chrome and Firefox suites concurrently, and scenarios within each browser run in parallel threads (thread-safe via
ThreadLocal<WebDriver>)
API (Simple Books API)
GET /status,GET /books,GET /books/{id}POST /api-clientsto generate a bearer token, thenPOST /ordersusing that tokenPATCH /orders/{id}to update an order, with a follow-up GET to verify the changeDELETE /orders/{id}, with a follow-up GET asserting a 404
- Java 17 (JDK)
- Maven (bundled with IntelliJ, or install separately)
- Google Chrome and Mozilla Firefox installed locally
- Git
No need to manually download chromedriver/geckodriver — WebDriverManager resolves and downloads the correct version automatically at runtime based on your installed browser version.
Run everything (UI on both browsers in parallel + API suite), via the TestNG suite file:
mvn clean testRun only Chrome:
mvn clean test -Dbrowser=chromeRun only Firefox:
mvn clean test -Dbrowser=firefoxRun headless (useful for CI):
mvn clean test -Dheadless=trueRun only a specific Cucumber tag (e.g. just smoke tests):
mvn clean test -Dcucumber.filter.tags="@smoke"After a run completes, open:
test-output/ExtentReport/SparkReport/Spark.html
This gives a full HTML report with pass/fail breakdown per scenario, and embedded screenshots for any failed UI step (captured automatically via the Cucumber Hooks class).
Cucumber's own basic HTML/JSON output is also available in target/cucumber-reports/ if needed for CI integrations.
- Page Object Model: every page interaction lives in a
pages/*Page.javaclass extendingBasePage, which centralizes explicit-wait logic. Step definitions never touch Selenium locators directly. - Thread safety:
DriverFactoryuses aThreadLocal<WebDriver>so that parallel TestNG threads (different browsers, or parallel scenarios within a browser) never share or clobber each other's driver instance. - Config externalization: browser choice, base URLs, and test credentials are all in
config.properties, with system property overrides (-Dbrowser=...) taking precedence — no hardcoded values in test logic. - API test ordering: the Simple Books API tests are intentionally sequential (
priority+dependsOnMethods) since order creation depends on a freshly generated token, and the PATCH/DELETE tests depend on that order existing. This keeps the flow readable rather than artificially independent.
- The empty-username/empty-password login scenarios use a Scenario Outline; if SauceDemo ever changes its exact error copy, only the
Examplestable needs updating. - Extent/Allure reports and
test-output/,target/are gitignored — they're generated artifacts, not source. - For CI (GitHub Actions, Jenkins, etc.), add
-Dheadless=trueto the Maven goal so Chrome/Firefox run without a display.