Check / Uncheck
Check / Uncheck
Section titled “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).
How it works
Section titled “How it works”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 withrole="checkbox"orrole="radio". A radio button can’t be unchecked withchecked = false: check another one in the same group.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The checkbox or radio button. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page | ZoanPageSession | — | The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page). |
checked | bool | true | true = check · false = uncheck. |
timeout | number | 30000 | Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000. |
Output
Section titled “Output”This activity does not return a value.
Example
Section titled “Example”Page Check selector = (#aceptoTerminos) // check (checked = true by default)Page Check selector = (#recibirPublicidad) checked = false // uncheckPage Check selector = (#envioExpress) checked = cliente["express"] == "S"Common errors
Section titled “Common errors”| Message | Cause 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. |
Related activities
Section titled “Related activities”- Click — for elements that aren’t checkboxes.
- Get Attribute — check the state by reading the
checkedattribute.