How the text visibility check decides

in Japanese(日本語)

exist and textIs first find the element in the tree (the accessibility tree). An element can be in the tree, though, while the screen shows something else on top of it, or while it is cut off outside a scrolling area. Text visibility check checks, on a screenshot, that the text of the element matched in the tree is actually drawn on screen, and fails the step when it is not.

It only checks whether the text is visible. Whether the value is the expected one is guaranteed by the tree check, so a different value is not its concern.

How it decides

The two run profile settings (ocrTextVisibilityCheck for OCR and fmTextVisibilityCheck for FM) are independent, and the check runs while either is on. With both on (the default):

  1. When the device's OCR reads the whole expected text, the step passes right there (fast).
  2. Otherwise FM (Foundation Models) also transcribes the text that is drawn, and both the transcript and the OCR reading (or, if nothing is legible, the amount of ink in the region) are matched against the expected text. The step passes if either reads the expected text and fails only when both find it not visible (reading the text is direct evidence it is drawn, while failing to read it also happens on a misread).
  3. When FM is unavailable (FM failing, or macOS 26), the same rules are applied to the OCR reading alone. On-device OCR is macOS 27+ only, so on macOS 26 neither stage can read text: the check can only fail on geometry or a blank region (no ink); otherwise it passes without confirming the text is drawn, and the step carries the note visual-text-check-unsupported.

With FM turned off (fmTextVisibilityCheck: false) the OCR reading alone decides; with OCR turned off (ocrTextVisibilityCheck: false) FM alone decides.

Turning OCR off makes the check slower and removes the judgement for when FM is unavailable (with both off, visual verification does not run). Even with OCR off, OCR re-reads the text when FM's transcription differs from the expected text by up to one character, or by up to the length of the normalized expected text ÷ 5 characters (2 for 10 characters), so that a mix-up of similar-looking characters does not fail the check by mistake (only then, OCR's first-time preparation can take up to 60 seconds).

An element whose centre is off the screen fails before any image is looked at.

Examples

The images are reproductions drawn in the iOS system font (SF, 17 pt) to show each shape. The OCR reading and the result are what the check actually returned for that image.

Visible: passes

Image Expected (tree) OCR reading Why
read in full Game Center Game Center Read in full
quotes “Calendar” updates "Calendar" updates Curly and straight quotes are normalized before matching
only the value differs Unread: 5 Unread: 3 Text close to the expected text is drawn, so it passes (the value itself is the tree check's job)
translucent overlay Game Center Game Center The overlay is translucent and the text under it can be read

Spaces, letter case, and full-width versus half-width characters are also normalized. When the expected text is five characters or longer, a misread of about one character (such as ¡Cloud for iCloud) is tolerated.

Only the beginning is drawn: passes with a note

Image Expected (tree) OCR reading Result
ellipsis Language & Region Language &... Passes with the note text-ellipsized (truncation the app intended)
part of the text is hidden Notifications Notificatio Passes with the note text-partially-hidden (more than half is visible)

Not visible: fails

Image Expected (tree) OCR reading Why it fails
most of the text is hidden Game Center Game Half or less is drawn (most of the text is hidden)
covered from the left Game Center Center Only the end is drawn, so the beginning is covered (covered)
nothing drawn Game Center (nothing legible) No text is drawn (notRendered)
fully covered Game Center (nothing legible) A plain overlay hides all of it (notRendered)
other text Game Center Walpaper Unrelated text is drawn there (textMismatch)

The failure message is text visibility check failed (on screen): present in the tree but not visually visible [<reason>] .... When FM is turned off and the OCR reading decided the failure it adds judged by OCR, and when FM is turned on but was unavailable and OCR alone decided it adds judged by OCR alone because FM gave no verdict. In both cases the step does not fail at once: it keeps taking new screenshots for its wait time (waitSeconds) and passes if the text becomes visible.

Shapes OCR cannot judge: FM decides

Image Expected (tree) OCR reading Result
FM decides Game Center (nothing legible) Nothing legible, but something like a button or an icon is drawn. FM transcribes it (nothing), matches that, and fails the step

OCR cannot judge a shape where another picture is drawn over the text, or where only part of the text is left. FM judges those. Where FM is unavailable, they pass unverified.

When a step fails

Limitations

Screen rendering check (iOS Simulator only)

On an iOS Simulator the app's drawing can break and stay broken until the app is relaunched, while the element tree still looks normal. The app area becomes a single colour, or shapes are drawn but no text at all. A check that only reads the element tree would pass on such a screen. When an assertion passes without the text visibility check having confirmed by pixels that text is drawn, the tool takes one screenshot at the next checkpoint (right before launchApp / restartApp / clearAppData / terminateApp, before afterEach, and at the end of the scenario). If the screenshot is still a single colour, or none of the text elements in the tree is drawn (at least 3 of them), after a retake 1 second later, the scenario fails with a step named screen rendering check (…). The message lists the facts: what was seen, and the names of the checks that passed without looking at the screen.

What to do: run the scenario again. If it keeps failing, relaunch the app (or restart the Simulator) and check that the app draws normally. This check does not run on physical devices or Android, and the tool does not say what caused the broken drawing.