PAPracticeAutomation
Se

Java ยท JUnit 5

Selenium

The veteran of browser automation. Drive real browsers through WebDriver from Java, Python, C#, JS or Ruby โ€” and learn explicit waits, the Actions API, frames, windows and alerts the way most enterprise suites still do it.

WebDriverWait & ExpectedConditionsActions API: hover, drag, keysFrames, windows & alertsShadow roots via getShadowRoot()

Pick a practice track

Two complete apps to automate end to end, plus focused element-handling recipes โ€” all in Selenium.

๐Ÿ›๏ธNova Shop

E-commerce app

Login with test users, search/filter/sort products, cart & coupons, a validated checkout, a declined card and order history.

  • โœ“3 test accounts incl. locked & slow
  • โœ“Cart maths, coupons, tax & shipping
  • โœ“Form validation + payment failure
๐ŸŽฌShowTime

Ticket booking app

Pick city, date and showtime, select seats on a live seat map, add snacks, apply promos and pay with an OTP step under a hold timer.

  • โœ“Seat map with tiers & limits
  • โœ“Countdown timer & clock mocking
  • โœ“OTP modal, async UPI, cancellations
๐Ÿงฉ50+ challenges

Elements handling

Focused recipes for inputs, dropdowns, tables, alerts, frames, windows, drag & drop, uploads, hover, waits, shadow DOM and keys.

  • โœ“15 copy-ready recipes
  • โœ“Each linked to a live challenge
  • โœ“Tool-specific gotchas called out

1. Set up

Run this site locally with npm run dev โ€” examples target http://localhost:3000.

pom.xml (Maven)
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.25.0</version>
</dependency>
<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter</artifactId>
  <version>5.11.0</version>
  <scope>test</scope>
</dependency>

2. Your first test

Sign in to Nova Shop and assert the product grid loaded.

FirstTest.java
import org.junit.jupiter.api.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.*;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.*;

class FirstTest {
  WebDriver driver = new ChromeDriver();   // Selenium Manager downloads the driver for you
  WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

  By tid(String id) { return By.cssSelector("[data-testid='" + id + "']"); }

  @Test
  void demoUserCanSignIn() {
    driver.get("http://localhost:3000/shop");
    wait.until(ExpectedConditions.elementToBeClickable(tid("username"))).sendKeys("demo_user");
    driver.findElement(tid("password")).sendKeys("Demo@123");
    driver.findElement(tid("login-button")).click();

    wait.until(ExpectedConditions.urlContains("/shop/products"));
    assertEquals(12, wait.until(
        ExpectedConditions.numberOfElementsToBe(tid("product-card"), 12)).size());
  }

  @AfterEach
  void tearDown() { driver.quit(); }
}

Official docs: https://www.selenium.dev/documentation/

Practising another tool?