Skip to main content

Mobile Troubleshooting

Exceptions​

ExceptionWhen
MobileServerUnavailableExceptionmobilecli is not reachable and could not be started: mobilecli is missing (mobilecliPath), exited, or did not answer within serverStartMs; the message names the log
MobileVersionExceptionmobilecli is older than 1.0.20
DeviceSelectionExceptionthe selectors match zero or several online devices, or no pool device is online
DeviceNotFoundExceptionmobilecli does not know the device
MobileLocatorExceptionstrict mode: several elements matched; an invalid selector string; a page field without a selector for the running platform
MobileTimeoutExceptionan action, @WaitFor or request ran out of time; the message lists the last elements seen
MobileAssertionErroran expect(...) did not pass in time
MobileRpcExceptionany other mobilecli error; a failed screen read names the agent check

Common problems​

SymptomCause and fix
mobilecli not found at 'mobilecli'mobilecli is not on the PATH of the test JVM (IDEs often have a shorter PATH). Set mobile.mobilecliPath to the full path (which mobilecli).
did not answer within 20000 msthe auto-started server is slow or failing; read target/mobilecli-autostart.log, or raise timeouts.serverStartMs.
Native mobile needs a 'mobile:' sectionthe active profile has no mobile: block; pass -Dtestfly.profile=<name> or add the block.
The first tap or @WaitFor times out on iOS ("reading the view tree timed out")DeviceKit is still starting on a fresh simulator. Read the screen once with a long timeout (see CI), or raise timeouts.rpcMs.
Every screen read fails on iOS, the message names the agentthe mobilecli agent is missing: mobilecli agent install --device <id> (Android needs no agent).
DeviceSelectionException on an Android emulatorthe id is the AVD name (Pixel_8_API_34), not emulator-5554.
Strict mode: … matched 2 elementsthe query is ambiguous, e.g. a Settings row is a Button that also holds a StaticText with the same label. Use a role (getByRole(BUTTON, "General")), a test id, or first().
A page object field is nullthe field has an initial value (= null) that overwrote the locator; remove it.
LoginPage.x: no android selectorthe @MobileFind has no android (or value) selector; add the Android id.
A Cucumber step times out creating a pagethe page's screen is already gone; keep the page instance from an earlier step.
Texts do not matchthe device language differs from the texts; prefer test ids.

Limits​

  • One device per test; a JVM-wide reservation lets only one test use a device at a time. Without a pool, parallel workers share one device serially. Separate JVMs or machines sharing devices are not coordinated.
  • App state cannot be cached like browser cookies, so a mobile @PreCondition runs again before every test unless mobile.app.reset: none keeps the app state. Cucumber does not read @PreCondition; use a Background.
  • launchApp does not wait for the app to reach the foreground; the first locator call waits instead.
  • No WebView or WebSocket support yet. Screen recording needs a local mobilecli server; a device that cannot record logs a warning and runs without a video.
  • Custom backends can implement the io.testfly.mobile.spi.MobileDriver interface and open a device with Mobile.connect(driver, settings).