tezvyn:

Locating XCUITest elements without accessibility identifiers

Source: interviewintermediate

WHAT IT TESTS: navigating the element query hierarchy. OUTLINE: query by type, label, predicate, or index; chain queries to narrow scope. RED FLAG: relying on brittle absolute indices or visible label text that breaks under localization and layout changes.

WHAT IT TESTS: whether you can locate elements robustly when identifiers are missing, and whether you grasp the brittleness cost. ANSWER OUTLINE: use XCUIElementQuery to filter by element type, then narrow by label, by NSPredicate matching, or by index within a container; prefer querying inside the relevant ancestor to scope tightly. Trade-off: label and index queries are fragile against localization, dynamic content, and reordering, whereas accessibility identifiers are stable, localization-proof contracts.

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Locating XCUITest elements without accessibility identifiers · Tezvyn