State assertion (enabledIsTrue, enabledIsFalse, checkIsON, checkIsOFF)

in Japanese(日本語)

Checks on the enabled/disabled and checked/unchecked state of the last grabbed element.

Functions

function description
select(selector).enabledIsTrue(waitSeconds:) Asserts the element is enabled. Waits up to waitSeconds for a state change. The target is the element grabbed last.
select(selector).enabledIsFalse(waitSeconds:) Asserts the element is disabled. Same waiting behavior.
select(selector).checkIsON(prefer:, waitSeconds:) Asserts the element is checked. prefer: picks the source to read the state from (.classifier / .accessibility) for this one command; omitted = the run profile decides.
select(selector).checkIsOFF(prefer:, waitSeconds:) Asserts the element is not checked. prefer: is the same as in checkIsON. Warns at the end of the run if the element never reported a checked state (on or off).

All four are chainable on the return value of exist / select, and each also has an implicit free-function form that acts on the last grabbed element (e.g. enabledIsTrue()).

Example

select("#login_btn").enabledIsFalse()
tap("#email"); type("test@example.com")
tap("#password"); type("password123")
select("#login_btn").enabledIsTrue()

select("#toggle_notifications").checkIsON()

Notes

Judging the checked state from images (CheckStateClassifier)

Parts whose accessibility reports no checked state can be judged by an image classifier trained from sample images.

<project>/vision/classifiers/CheckStateClassifier/
  [ON]/             sample images of the "on" state (png / jpg)
  [OFF]/            sample images of the "off" state
  [INDETERMINATE]/  sample images of the partially checked state (optional)