Playwright / Quiz

Needle, Meet Haystack

filter(), has, chaining, and or(): surgical targeting in lists and tables where twelve rows all look the same.

Difficulty
Medium
Format
Quiz
Points
150
Estimate
10 min

// MISSION BRIEF

Your Mission

The table has forty rows, each with its own Delete button. Click the wrong one and the test just deleted the wrong customer.

This quiz drills Playwright's narrowing toolkit: filter({ hasText }), filter({ has }), locator chaining, or(), and the honest, limited role of nth().

Speed bonus active.

// FIRST CONTACT

Battle teaser

You need the list item containing the text 'Falcon Drone'. The idiomatic narrowing:

  1. Apage.getByText('Falcon Drone').locator('..')
  2. Bpage.getByRole('listitem').filter({ hasText: 'Falcon Drone' })
  3. Cpage.locator('li:nth-of-type(5)')
  4. Dpage.getByRole('listitem').nth(4), it is the fifth item today
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

playwrightlocatorsfilteringtypescripte2e-testing