Skip to content
CodeKruPro

Check and Uncheck Checkboxes

21/70

Check and Uncheck Checkboxes

Playwright provides dedicated methods for checkboxes:

  • locator.check() — checks the checkbox (no-op if already checked)
  • locator.uncheck() — unchecks the checkbox
  • locator.isChecked() — returns whether it is checked

On the Checkboxes page, #firstSelect1 is an unchecked checkbox.

Task:

  1. Navigate to https://testkru.com/Elements/Checkboxes
  2. Print whether #firstSelect1 is checked (should be false)
  3. Check it
  4. Print whether it is checked now (should be true)
  5. Uncheck it
  6. Print final state (should be false)

Expected output:

Initially checked: false
After check: true
After uncheck: false