Playwright + TS · Lesson 21 of 36
Module 21: Web Elements
Try it yourself
Implement parseTableRow:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
To verify or click an element inside a dynamic table row:
// Find row containing user email and click its 'Edit' button
const row = page.locator("table tbody tr", { hasText: "jane.doe@example.com" });
await row.getByRole("button", { name: "Edit" }).click();
// Extract all table row texts:
const allNames = await page.locator("table tbody tr td:first-child").allInnerTexts();Custom dropdowns that query an API as the user types:
const searchInput = page.getByPlaceholder("Search countries");
await searchInput.pressSequentially("Jap", { delay: 100 });
// Wait for floating suggestions dropdown and select target
const option = page.getByRole("option", { name: "Japan" });
await option.click();Rather than clicking calendar arrow buttons 50 times, preferred strategies:
await page.getByLabel("Departure Date").fill("2026-10-15");await page.getByLabel("Choose date").click();
await page.getByRole("gridcell", { name: "15" }).click();async function scrollDownTimes(page: Page, times: number) {
for (let i = 0; i < times; i++) {
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await page.waitForTimeout(500); // Wait for next batch of items
}
}Modern web applications are filled with complex widgets like data tables, auto-complete dropdowns, date pickers, and infinite scrolling lists. In this lesson, we will learn reliable automation patterns to interact with dynamic web components smoothly and consistently. Let's tackle complex UI elements!
Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
You can fill the slider input if it has an <input type='range'>, or dispatch keyboard ArrowRight / ArrowLeft events to adjust it accurately.
Rich text editors often use contenteditable='true' divs or nested iframes. Target the contenteditable container with locator('[contenteditable="true"]').fill('Text').
Finished reading?
Review the worked example in the editor, then mark the lesson complete.