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:
- Navigate to
https://testkru.com/Elements/RadioButtons - Find ALL radio buttons with
page.locator()and a CSS selector that matchesinputelements of typeradio - Print the total count using
.count() - Print the ID of the first radio button, using
.first()andgetAttribute()
Expected output:
Total radio buttons: 15 First radio ID: firstSelect1
TestKru