Skip to content

Check / Uncheck

Type: page-check  ·  Package: Browser v1.0.9

Checks or unchecks a checkbox or a radio button. Unlike a plain Click, it guarantees the final state you want: if you ask to check it and it’s already checked, it stays checked (it doesn’t toggle it).

It locates the element by its selector and brings it to the state given by checked: true checks it, false unchecks it. That’s why it’s more reliable than a click, which simply toggles the state.

  • If it’s already in the requested state, it does nothing (it is idempotent).
  • Otherwise it waits until it’s actionable (like Click), clicks it and verifies the state changed; if it didn’t, it fails.
  • It works with <input type="checkbox">, <input type="radio"> and elements with role="checkbox" or role="radio". A radio button can’t be unchecked with checked = false: check another one in the same group.
ParameterTypeDefaultDescription
selectorselector—The checkbox or radio button.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page).
checkedbooltruetrue = check · false = uncheck.
timeoutnumber30000Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000.

This activity does not return a value.

Page Check selector = (#aceptoTerminos) // check (checked = true by default)
Page Check selector = (#recibirPublicidad) checked = false // uncheck
Page Check selector = (#envioExpress) checked = cliente["express"] == "S"
MessageCause and fix
Check failed: Timeout 30000ms exceeded. … | matches: 0 (…)It didn’t find the checkbox. Check the selector or wait first with Wait For.
Check failed: Not a checkbox or radio button …The selector points to another element (for example, the label or a container). Capture the checkbox input.
Check failed: Clicking the checkbox did not change its state …The page reverts the click (custom JavaScript checkboxes). Use Click on the visible element and verify the result with Get Attribute.
'page' must be a ZoanPageSession.There is no page and the activity isn’t inside a body.
  • Click — for elements that aren’t checkboxes.
  • Get Attribute — check the state by reading the checked attribute.