Back to Courses
FOR SELENIUM PROFESSIONALS — MODERN AUTOMATION

Playwright with Java

A comprehensive 30-day course covering the complete Playwright Java API — locators, element actions, wait strategies, TestNG, ExtentReports, Apache POI, POM design pattern, GitHub, and a live automation framework. Built for engineers who want industry-ready skills.

30+
Days of Training
14
Modules
100+
Topics Covered
Live
Framework

 Who Is This Course For?

This course is designed for Java and Selenium engineers who are ready to adopt Playwright — Microsoft's modern, next-generation browser automation framework. You will master the full Playwright Java API, build a production-grade POM framework, integrate TestNG and ExtentReports, handle real-world test challenges, and leave with a complete, GitHub-hosted framework ready for your portfolio.

Playwright Java API CSS & XPath Locators TestNG Integration ExtentReports Apache POI — Excel Page Object Model GitHub & SCM Live Framework Project

🚀 Course Progression

Each module builds toward a production-grade Playwright automation framework used in real companies.

1Playwright & Locators
2Actions & Waits
3TestNG & Reports
4Full Framework
🏆Playwright Pro!
MODULE 01  Introduction to Playwright & Project Setup
💡 Why This Module Matters: Playwright is rapidly replacing Selenium at many top companies. Understanding its architecture from day one helps you write clean, reliable tests — and gives you a strong answer when interviewers ask "why Playwright over Selenium?"
What is Playwright?
  • Playwright — free, open-source Microsoft framework (2020); supports Chromium, Firefox, WebKit from one API
  • Key advantages: built-in auto-waiting, network interception, Trace Viewer, no driver manager needed
  • Creating a Maven project; adding com.microsoft.playwright dependency to pom.xml
First Playwright Script
  • Playwright.create()playwright.chromium().launch()browser.newContext()context.newPage()
  • LaunchOptions: setHeadless(false) to run with a visible browser window
  • Try-with-resources pattern — auto-closing Playwright, Browser, and Page objects
MODULE 02  Java Essentials Recap
💡 Why This Module Matters: Playwright's Java API uses lambdas and functional interfaces in many places — for event handlers, wait conditions, and frame lookups. A solid recap here means you'll read and write Playwright code confidently without confusion.
OOP & Constructors
  • Static vs non-static variables and methods — class-level shared state vs instance-level state
  • Constructor chaining with this(); this. keyword to differentiate instance and local variables
  • Inheritance and super — used in BaseTest pattern across the full framework
Lambda & Functional Interfaces
  • @FunctionalInterface — interfaces with exactly one abstract method; lambda shorthand
  • Lambda syntax: (params) -> expression; used in page.frameByUrl(url -> url.contains("..."))
  • Built-in functional types: Predicate<T>, Consumer<T>, Function<T,R>, Supplier<T>
MODULE 03  Page Navigation & Browser Control
💡 Why This Module Matters: These are the first methods you call in every test. Knowing how to read page state (title, URL, content) and control navigation precisely is the foundation of every reliable test script you will ever write.
Navigation & Page State
  • page.navigate("url") — load a URL; page.goBack() / page.goForward() / page.reload()
  • page.title(), page.url(), page.content() — read back page information
  • page.close() / browser.close(); page.waitForTimeout(ms) — hard wait (use sparingly)
  • Multiple browser contexts — isolated sessions with separate cookies and storage state
MODULE 04  Built-in Locators
💡 Why This Module Matters: Playwright's built-in locators are designed to be resilient and readable — they find elements the same way a real user would. Choosing the right locator is the most important skill for writing tests that don't break every time the page changes.
Semantic Locators
  • page.getByLabel("text"), page.getByPlaceholder("text"), page.getByAltText("text")
  • page.getByTitle("text"), page.getByText("text"), page.getByTestId("id")
  • page.getByRole(AriaRole.BUTTON) — ARIA role-based locator; GetByRoleOptions.setName("label")
  • page.locator("selector") — CSS or XPath; LocatorOptions.setExact(true) for exact matching
  • page.pause() — opens Playwright Inspector for live locator debugging in the browser
Handling Multiple Matches
  • locator.first(), locator.nth(index), locator.last() — target a specific match
  • locator.all() — returns List<Locator>; iterate all matching elements in a loop
MODULE 05  CSS Selectors
💡 Why This Module Matters: CSS selectors are faster and easier to read than XPath. Most front-end developers think in CSS — learning it well means your locators match how the application is actually built, and makes code reviews with developers much smoother.
CSS Selector Syntax
  • #id — ID selector; .class — class selector; tag — element type
  • tag[attribute='value'] exact match; ^= starts-with; *= contains; $= ends-with
  • Combining: tag.class#id[attr='val'] — all conditions on the same element
  • Relational: parent child (descendant), parent > child (direct child), + adjacent sibling
  • Pseudo-classes: :nth-child(n), :first-child, :last-child for positional targeting
MODULE 06  XPath
💡 Why This Module Matters: XPath is the fallback when no CSS or semantic locator works — for example, when you need to find a parent by a child's text, or navigate the DOM tree sideways. Knowing XPath well is what separates average testers from seniors in interviews.
XPath Fundamentals
  • Relative XPath: //tag[@attribute='value'] — robust, preferred over absolute paths
  • contains(@attr,'partial'), starts-with(@attr,'prefix'), ends-with(@attr,'suffix')
  • //tag[text()='exact text'] — match by visible text content
  • Logical operators: and, or, not() in predicates
Advanced XPath
  • Index: (//tag[@attr='val'])[1] — select nth occurrence (1-based indexing)
  • Parent navigation: //child/../sibling — move up the DOM tree to find siblings
  • Axes: following-sibling::tag, preceding-sibling::tag, ancestor::tag
  • Using XPath in Playwright: page.locator("xpath=//...") with explicit prefix
MODULE 07  Element Actions
💡 Why This Module Matters: This is the heart of test automation — every test you write involves interacting with elements. Playwright's action methods auto-wait for elements to be ready before acting, making your tests far more stable than Selenium's equivalent methods.
Input & Click Actions
  • locator.fill("text") — clear and type; locator.press("Enter"), "Tab", "ArrowDown"
  • locator.click(), locator.dblClick(), locator.hover(), locator.clear()
  • locator.check() / locator.uncheck(); locator.dragTo(targetLocator)
State Verification & Advanced
  • locator.isChecked(), locator.isDisabled(), locator.isEnabled(), locator.isVisible()
  • locator.getAttribute("name"), locator.textContent(), locator.innerText(), locator.innerHTML()
  • locator.boundingBox() — returns {x, y, width, height} for position calculations
  • locator.screenshot() — capture a screenshot of just this element
  • page.onceDialog(dialog -> dialog.accept()) — handle JS alert / confirm / prompt pop-ups
MODULE 08  iFrames & Listbox
💡 Why This Module Matters: iFrames appear in payment gateways, ads, chat widgets, and third-party integrations. Playwright handles them without the painful "switchTo().frame()" context switching that Selenium requires — making your tests cleaner and less error-prone.
Working with iFrames
  • page.frame("frameName") — access by name attribute; returns Frame object
  • page.frameLocator("#frameId") — access by CSS selector; returns FrameLocator
  • page.frameByUrl(url -> url.contains("part")) — access by URL pattern using lambda
  • Chain locators inside frame: frameLocator.locator("input").fill("text")
  • Nested iFrames: frameLocator().frameLocator() — chain multiple levels
Listbox — selectOption()
  • locator.selectOption("visibleText") — select by label; .setValue("val") by value attribute
  • .setIndex(2) — select by position; .setLabel("label") — select by label attribute
  • Multi-select: passing an array of values; limitations with non-standard controls
MODULE 09  JavaScript Execution & Scrolling
💡 Why This Module Matters: Some elements — like hidden date pickers, read-only fields, or dynamically loaded content — cannot be interacted with using standard Playwright actions. JavaScript execution is your escape hatch for these edge cases, and it comes up in almost every real project.
JavaScript Execution
  • page.evaluate("JS expression") — run JavaScript in the browser; return value to Java
  • Passing Java values into JS: page.evaluate("(val) => document.getElementById('id').value = val", "text")
  • Reading JS values: (String) page.evaluate("window.location.href")
Scrolling Techniques
  • locator.scrollIntoViewIfNeeded() — auto-scroll element into the visible viewport
  • page.mouse().wheel(deltaX, deltaY) — programmatic mouse wheel scroll up/down/left/right
  • Scroll to bottom: page.evaluate("window.scrollTo(0, document.body.scrollHeight)")
MODULE 10  Wait Strategies & Synchronisation
💡 Why This Module Matters: Flaky tests — tests that pass sometimes and fail other times — are usually caused by bad wait strategies. Playwright auto-waits before every action, but knowing when and how to add explicit waits is what makes your tests rock-solid in CI/CD pipelines.
Timeout Configuration & Hard Waits
  • page.setDefaultTimeout(ms) — global timeout for all actions; setDefaultNavigationTimeout(ms) for navigation
  • Playwright auto-waiting — built-in retries on actionability (visible, enabled, stable) before every action
  • page.waitForTimeout(ms) — hard wait; avoid except as last resort
Smart Wait Methods
  • locator.waitFor() — waits until locator is actionable; page.waitForSelector("css")
  • page.waitForURL("url"); page.waitForLoadState(LoadState.NETWORKIDLE)
  • page.waitForPopup() / page.waitForClose() — sync with new windows
  • page.waitForCondition(BooleanSupplier) — custom condition wait
  • page.waitForDownload(); page.waitForFileChooser(); page.waitForFunction("JS")
  • assertThat(locator).isVisible() — Playwright assertion; retries for 5 seconds by default
MODULE 11  TestNG Integration
💡 Why This Module Matters: Playwright gives you browser control, but TestNG gives you test management — the ability to run thousands of tests in the right order, in parallel, with the right data, and with meaningful reports. This combination is what real enterprise QA teams use every day.
Annotations & Lifecycle
  • @Test: priority, enabled, groups, dependsOnMethods
  • Lifecycle: @BeforeSuite, @BeforeTest, @BeforeClass, @BeforeMethod → test runs → @AfterMethod, @AfterClass, @AfterTest, @AfterSuite
  • testng.xml — suite config; Reporter.log("msg") → appears in emailable-report.html
Data-Driven & Parallel Execution
  • @DataProvider(name="dp") + @Test(dataProvider="dp") — run one test with multiple data rows
  • @Parameters({"param"}) — read environment/browser from testng.xml
  • Parallel: parallel="methods" / "classes" / "tests" in testng.xml
  • Groups: include, exclude, alwaysRun=true
Assertions
  • Assert.assertEquals(actual, expected) — hard assert; stops test on first failure
  • SoftAssert sa = new SoftAssert(); sa.assertAll() — collect all failures, report together
  • Re-run failed tests using surefire-reports/testng-failed.xml
MODULE 12  Reporting & Data Handling
💡 Why This Module Matters: Managers and stakeholders don't read code — they read reports. A professional HTML test report with screenshots of failures is what proves your automation delivers value. Excel-driven testing shows you can scale tests without changing code.
ExtentReports Integration
  • ExtentSparkReporter — HTML report path and theme; ExtentReports.attachReporter()
  • extent.createTest("name") — create test entry; test.pass(), test.fail(), test.skip(), test.info()
  • Attach screenshot on failure: test.fail(MediaEntityBuilder.createScreenCaptureFromPath("path").build())
  • Static vs non-static placement of ExtentReports object in @BeforeSuite / @AfterSuite
Property Files & Apache POI
  • config.properties — browser, URL, credentials outside code; Properties.load(FileInputStream), p.getProperty("key")
  • Apache POI: poi and poi-ooxml Maven dependencies
  • XSSFWorkbookXSSFSheetXSSFRowXSSFCell.getStringCellValue()
  • Loop Excel rows into @DataProvider for fully data-driven test execution
MODULE 13  Grid, Remote Execution & Cloud
💡 Why This Module Matters: Running tests only on your laptop is not enough for a real project. Clients expect tests to run across multiple browsers, operating systems, and environments. Playwright makes remote and cloud execution much simpler than Selenium Grid ever was.
Remote Playwright Server
  • npx playwright install — install browsers on the server machine
  • npx playwright run-server --port=7777 — start remote WebSocket server
  • playwright.chromium().connect("ws://hostname:7777") — connect Java client to remote server
  • npx playwright show-trace trace.zip — open Trace Viewer for step-by-step test debugging
Cloud Execution
  • BrowserStack: playwright.chromium().connect("wss://cdp.browserstack.com/...") with username + access key
  • MCP (Microsoft Cloud Playwright) — fully managed, no infrastructure to maintain
  • Parallel cloud execution — cross-browser, cross-OS matrix in a single test run
MODULE 14  Page Object Model & Complete Framework
💡 Why This Module Matters: This is what separates a "tester who knows Playwright" from a "Playwright automation engineer." Building a maintainable, scalable POM framework from scratch is the number one thing employers test for in technical interviews — and now you have one to show them.
POM Design Pattern
  • Manual test case → automation: page → elements → actions mapping strategy
  • Page classes: LoginPage, HomePage etc.; constructor accepting Page object
  • BaseTest class with shared @BeforeSuite, @BeforeMethod, @AfterMethod, @AfterSuite
  • Test classes extend BaseTest — inherit browser setup/teardown; focus only on test logic
Full Framework Execution Flow
  • @BeforeSuite — initialise ExtentSparkReporter + ExtentReports; create Playwright instance
  • @BeforeMethod — read config.properties; launch browser; setDefaultTimeout(); navigate to URL
  • @Test — read Excel via POI; call POM page methods; Assert results; log to ExtentTest
  • @AfterMethod — screenshot on failure; close page + browser; save video if enabled
  • @AfterSuiteextent.flush() to write HTML report; close playwright
GitHub & Version Control
  • Create GitHub repo with .gitignore for Java/Maven; generate personal access token
  • Eclipse Team/Git: Team > Share Project; push to origin main
  • Import from GitHub: Import > Git > Projects from Git
Interview Preparation

Playwright vs Selenium — Auto-waiting, Page replaces WebDriver, built-in assertions, no driver manager, network mocking out of the box

Locator PrioritygetByRolegetByLabelgetByTestId → CSS → XPath. Most resilient to UI changes first

Wait Strategy — Playwright auto-waits before every action; waitForTimeout only as absolute last resort; prefer waitFor() or assertThat()

Framework DesignBaseTest for setup/teardown, page classes for each screen, config.properties for env, Excel for data, ExtentReports for visibility

iFrame HandlingframeLocator() returns a FrameLocator; chain locators directly; no need for switchTo().frame() like in Selenium

Cloud Testing — One-line change: playwright.chromium().connect("wss://...") replaces local launch; BrowserStack or MCP for cross-browser matrix