A Java-based UI test automation framework built while learning Selenium WebDriver through Test Automation University. The project covers a wide range of real browser interaction patterns using the Page Object Model, TestNG, and Maven.
Test site: The Internet (Herokuapp) — a purpose-built site for practicing browser automation across common UI patterns.
| Tool | Purpose |
|---|---|
| Java | Primary language |
| Selenium WebDriver 4.x | Browser automation |
| TestNG | Test framework — lifecycle hooks, assertions, reporting |
| Maven | Build tool and dependency management |
| ChromeDriver | Chrome browser driver (auto-managed via Selenium 4) |
src/
├── main/java/
│ ├── Pages/ # Page Object classes — one class per page
│ └── utils/ # Shared utilities (WindowManager)
└── test/java/
├── base/ # BaseTests — driver setup, teardown, screenshot on failure
├── alerts/ # JS Alert, Confirm, Prompt tests
├── DropDown/ # Dropdown selection + multi-select via JS injection
├── frames/ # iFrame and nested frame interaction
├── hover/ # Mouse hover via Actions class
├── JavaScript/ # JavascriptExecutor — scroll, infinite scroll, DOM manipulation
├── Keys/ # Keyboard input — special keys and key combinations
├── login/ # Form authentication
├── Navigation/ # Tab switching, back/forward/refresh navigation
├── Slider/ # Horizontal slider via arrow keys
└── Wait/ # Explicit and Fluent wait strategies
All test classes extend BaseTests, which handles:
- Driver initialization with
@BeforeClass— one ChromeDriver instance per test class - Reset to home with
@BeforeMethod— navigates back to the base URL before every test, preventing state bleed between tests - Teardown with
@AfterClass— callsdriver.quit()to close the browser and release ChromeDriver - Screenshot on failure with
@AfterMethod— automatically captures a screenshot if a test fails and saves it toresource/Screenshots/
Each page of the test site has a dedicated class in Pages/. Page classes:
- Own all locators (
Byfields) for that page - Expose methods for actions (click, input, retrieve text)
- Return the next page object when navigation occurs — enabling method chaining in tests
- Receive the
WebDriverinstance via constructor — no static driver, clean dependency injection
Test classes stay thin — they call page methods and assert results. Locator changes only need to be updated in one place.
A utility class that wraps WebDriver.Navigation and window handle management, exposing cleaner methods (goBack(), switchTab(title)) instead of raw driver calls in test code.
By.id,By.cssSelector,By.xpath,By.linkText,By.className,By.tagNamefindElement()vsfindElements()— single element vs list
click(),sendKeys(),getText(),getAttribute(),clear()- Keyboard keys via
Keysclass —Keys.BACK_SPACE,Keys.ARROW_RIGHT,Keys.chord()for combinations - File upload via
sendKeys(absoluteFilePath)— bypasses OS file picker
moveToElement()— hovercontextClick()— right click- Method chaining with
.perform()
Selectclass —selectByVisibleText(),getAllSelectedOptions()- Multi-select enabled at runtime via
JavascriptExecutorattribute injection
switchTo().alert()— JS Alert, Confirm, and Promptaccept(),dismiss(),getText(),sendKeys()
switchTo().frame(name)— enter frame contextswitchTo().parentFrame()— return to parent frame- Nested frame traversal — enter top frame, then child frame, return correctly
getWindowHandles()— iterate open tabsswitchTo().window(handle)— switch by title matchnavigate().back(),.forward(),.refresh(),.to(url)
scrollIntoView()— scroll to elementwindow.scrollTo()— page-level scroll for infinite scroll trigger- DOM attribute manipulation —
setAttribute('multiple', '')on dropdown
- Explicit Wait (
WebDriverWait) — wait for a specificExpectedCondition - Fluent Wait — configurable polling interval and exception ignoring during wait period
TakesScreenshotcast — capturesOutputType.FILEon test failure- Saved automatically to
resource/Screenshots/{testName}.png
Prerequisites: Java 17+, Maven, Chrome browser installed
# Clone the repo
git clone https://github.com/AnantNegi04/Selenium_automation_testing.git
cd Selenium_automation_testing
# Run all tests
mvn test
# Run a specific test class
mvn test -Dtest=LoginTests
# Run a specific test method
mvn test -Dtest=AlertsTests#testAcceptAlertReturning page objects from navigation methods
// Test reads like a user story
LoginPage loginPage = homePage.clickFormAuthenticationLink();
loginPage.setUserName("tomsmith");
loginPage.setPassword("SuperSecretPassword!");
SecureAreaPage secureArea = loginPage.clickLoginButton();
assertTrue(secureArea.getHeaderText().contains("You logged into a secure area!"));Fluent Wait for dynamic content
FluentWait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(10))
.pollingEvery(Duration.ofSeconds(1))
.ignoring(NoSuchElementException.class);
wait.until(ExpectedConditions.presenceOfElementLocated(loadedText));JavascriptExecutor for DOM manipulation
String script = "arguments[0].setAttribute('multiple', '')";
((JavascriptExecutor)driver).executeScript(script, findDropdownOption());DropDown.javaandDropDownPage.javaare two separate implementations of the same page —DropDown.javais the earlier version,DropDownPage.javais the extended version with multi-select and JS injection support- Event listener implementation was skipped —
EventFiringWebDriverwas deprecated and removed in Selenium 4; the Selenium 4 equivalent usesWebDriverListenerinterface withEventFiringDecorator DynamicLoadingExample1Pageshows bothWebDriverWait(commented out) andFluentWaitimplementations side by side for comparison
Built as part of a structured learning path toward SDET roles. Next phase: applying this framework to a real-world application.