Skip to content
CodeKruPro

Find Multiple Elements

9/70

Find Multiple Elements

In Playwright, page.locator(selector) returns a Locator that can match multiple elements. Use .all() to get an array, or .count() for the count.

On the Radio Buttons page, there are multiple radio button inputs.

Read an element's ID with getAttribute('id') — the same method you used in earlier exercises.

Task:

  1. Navigate to https://testkru.com/Elements/RadioButtons
  2. Find ALL radio buttons with page.locator() and a CSS selector that matches input elements of type radio
  3. Print the total count using .count()
  4. Print the ID of the first radio button, using .first() and getAttribute()

Expected output:

Total radio buttons: 15
First radio ID: firstSelect1