Skip to content

tvOS traps ​

Where web or mobile intuition is wrong on tvOS.

  • No click, no tap. There is no pointer. Move focus with the D-pad, act with SELECT. focus.pressUntilFocused presses a direction until the target holds focus.
  • testId is accessibilityIdentifier. Set it with .accessibilityIdentifier("x") (SwiftUI), accessibilityIdentifier (UIKit) or testID (React Native). XCUITest's name falls back to the label; toets deliberately ignores that fallback.
  • SwiftUI identifiers leak into children. An identifier on a stack is applied to every child. Add .accessibilityElement(children: .contain) to the container first.
  • Text belongs to the deepest element. getByText('Play') can resolve to the StaticText inside a button, which is never focused. focus.pressUntilFocused and navigateTo accept it once the button around it holds focus; toBeFocused() does not. Assert focus on a testId, not on text.
  • System alerts are not app alerts. appium:autoDismissAlerts does not dismiss every system prompt; App Tracking Transparency's stays up and takes focus. Do not request tracking authorization when toets launched the app: getLaunchPayload() from the SDK is defined then, or pass a launch argument (app.tvOS.launchArguments) that the test build checks. If a prompt must be part of the test, it is on screen like any element: press to its button with focus.pressUntilFocused(Key.UP, app.getByText('Ask App Not to Track')) and press SELECT.
  • Accessible elements speak for their subtree. A button's text is its accessibility label; if the label differs from what is drawn, assertions see the label.
  • BACK at the root leaves the app. The Menu button on a root screen sends the app to the background, like a user would.
  • focusable is inferred. XCUITest has no focusable flag; custom .focusable() views count once they hold focus or carry the Button trait.
  • Refs follow the screen structure. Element refs are tree paths; after the screen changes, re-resolve the locator (the core does this for you).
  • Presses during a screen transition are dropped. For about 350ms after a push or pop nothing has focus and the focus engine ignores the remote, although the new screen is already in the tree. The driver does not wait for focus: assert it on the new screen (toBeFocused, or toHaveFocusWithin on the screen) before the next press. toBeVisible passes too early. Apps with a JS focus engine assert the focus they report with reportFocus().
  • Down only reaches what is below. The focus engine moves to elements that overlap the focused one along the movement axis. A button at the far left is unreachable with DOWN from a card on the right; on web and Android TV spatial navigation often reaches it.
  • React Native joins texts into labels. An accessible view (a touchable card, a switch row) gets its children's texts joined with , as its label, e.g. Northern Lights, 2025 · Drama or Autoplay, Start playback automatically, On. Use toContainText, or assert on the testId of the text itself.
  • React Native plain views lose their children. XCUITest flattens a non-accessible view with a testID (a screen, a rail) into an empty element; its children appear as its siblings. Scoping into it and toHaveFocusWithin on it need the toets SDK; without it, assert on the focused element's testId.
  • Offscreen list items are there but invisible. A FlatList keeps cards outside the viewport in the tree with visible: false; toBeVisible on them fails until focus scrolls them in.
  • Reads never wait. The driver disables XCUITest's wait-for-idle, so reads return the current state immediately and the core's retries do the waiting. Animations are in flight while you assert; assert on end states.
  • Clearing data keeps the container folders. launch({ clearData: true }) and app.reset() run XCUITest's mobile: clearApp, which also deletes tmp/ and Library/Caches. The driver recreates Documents, Library/Caches, Library/Preferences and tmp afterwards, because apps expect them: a React Native debug build writes the Metro bundle to NSTemporaryDirectory() and shows "The folder 'ReactNativeDevBundle.js' doesn't exist" without it.
  • The first run builds WebDriverAgent. Expect about a minute once per Xcode version; cache it on CI (see setup).
  • One simulator per worker. Focus is global to the device.