[{"data":1,"prerenderedAt":22},["ShallowReactive",2],{"blog-post-en-test-android-app-offline-recovery-phoma":3},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":14,"thumbnail_url":18,"translations":19,"body":20,"asset_base":21},"test-android-app-offline-recovery-phoma","en","Test Android App Offline and Recovery Behavior with Phoma","A step-by-step guide to building Phoma flows that cut network access, verify offline states, and confirm recovery when Android apps reconnect.","2026-12-03",[10,11,12,13],"android testing","phoma","offline testing","qa automation",[15,11,16,17],"android-testing","offline-testing","qa-automation","https://blog-api.phomaapp.com/api/blog/posts/test-android-app-offline-recovery-phoma/thumbnail.svg?lang=en",[5],"Offline behavior is where many Android apps quietly fail. A screen that looks fine on Wi-Fi can show a stale list, a blank error, or a spinner that never stops when the phone drops offline. Phoma is a Windows desktop app that controls Android phones, and its visual flow builder is a practical way to check those states without writing code. This guide walks through one focused pattern: cut network access with Android's Airplane mode, verify the app's offline state, restore the network, and confirm recovery. Flows run on your own computer and phones, and everything on your own phones is free with no limit on phones or flows.\n\n## Why test offline and recovery as one flow\n\nTesters often check offline and online in separate runs. That hides the most important regression: what happens during the transition. A good flow should prove three things:\n\n- The app shows a clear offline state instead of crashing or spinning forever.\n- Any action that needs the network fails gracefully and does not corrupt local state.\n- When the network returns, the app recovers, retries, or tells the user what to do.\n\nCombining the checks also catches timing bugs. For example, an app may show `No internet connection` only after a refresh, or it may silently queue an order and send it after reconnect. A single flow can verify both sides of that contract.\n\n## Before you build the flow\n\nUse a dedicated test phone or a clean test profile. You need:\n\n- A build with a known offline screen, such as a text label `No internet connection` or a retry button.\n- Quick Settings access on the phone. Some device policies hide it, so confirm this first.\n- A selector for the Airplane mode tile. On many phones it is exposed as `content-desc = 'Airplane mode'`; on others it may be `text = 'Airplane mode'` or a resource ID.\n- A stable app screen selector after launch, such as `content-desc = 'Home'` or `text = 'Shop'`.\n\nDo not rely on fixed sleeps for app readiness. Use a short settle wait only for the network change, then wait for an element.\n\n### What to confirm first\n\nOpen the app manually once and inspect the element tree. Confirm the exact label for the offline message and the online-only element. If the app uses a custom view, OCR may be needed, but a text or content-desc selector is more stable when available.\n\n## Step 1: Open the app and confirm the online baseline\n\nStart the flow with the phone on Wi-Fi or mobile data. This baseline matters because it proves the selectors are correct before you change the network.\n\n1. Open the app.\n2. Wait for the home screen element.\n3. Tap the section that will be used later, such as Orders.\n4. Wait for a known online-only element, such as `text = 'Recent orders'`.\n5. Take a screenshot as a baseline checkpoint.\n\nIf this fails, fix selectors or app state before adding offline steps. A flow that cannot find the online state will produce misleading offline failures.\n\n## Step 2: Turn on Airplane mode from Quick Settings\n\nUse the phone's own Quick Settings rather than a system setting path that changes between manufacturers.\n\n1. Swipe down from the top of the screen twice to expand Quick Settings.\n2. Tap the Airplane mode tile.\n3. Wait about two seconds for the radio to settle.\n4. Open or return to the app.\n5. Trigger the network-dependent action, such as tapping Refresh or opening Orders.\n\nIllustrative Phoma steps:\n\n```\nSwipe\n  direction: down\n  times: 2\n\nTap\n  selector: content-desc = 'Airplane mode'\n\nWait\n  seconds: 2\n\nOpen app\n  package: com.example.shop\n\nTap\n  selector: text = 'Orders'\n\nWait for element\n  selector: text = 'No internet connection'\n  timeout: 10s\n```\n\nThe exact selector syntax in your Phoma build may look different; the important part is the sequence. Use the element tree inspector to confirm the tile and the offline message before saving the flow.\n\n### If Quick Settings is blocked\n\nSome managed devices hide Quick Settings. In that case, use a test profile with a debug network toggle, or open Android Settings and navigate to Network & internet, then Airplane mode. Keep that path in a separate sub-flow so one change does not break every flow.\n\n## Step 3: Assert the offline state and capture evidence\n\nAfter the offline action, read the text on screen and use a condition.\n\n- If the text contains `No internet connection`, `Offline`, or your app's equivalent, mark the step as passed.\n- If the expected text is missing, take a screenshot and fail the flow with a clear message.\n- If the app shows a retry button instead of text, wait for that button and assert its presence.\n\nExample condition logic:\n\n```\nRead text\n  selector: text = 'No internet connection'\n  store as: offlineMessage\n\nCondition\n  if offlineMessage contains 'No internet'\n    pass\n  else\n    screenshot: offline-failure.png\n    fail: expected offline message\n```\n\nScreenshot evidence is useful when the app's offline design changes. It also helps a developer see whether the phone was truly offline or the app simply showed an old cached screen.\n\n## Step 4: Restore the network and verify recovery\n\nRecovery is the half most teams skip. The flow should prove the app notices the network is back.\n\n1. Swipe down twice to open Quick Settings.\n2. Tap Airplane mode again to turn it off.\n3. Wait about three seconds for the network to reconnect.\n4. Open the app.\n5. Tap Retry, Refresh, or the same Orders action.\n6. Wait for the online-only element from the baseline, such as `text = 'Recent orders'`.\n7. Read a status text if the app shows one, such as `Connection restored`.\n8. Take a final screenshot.\n\n```\nTap\n  selector: content-desc = 'Airplane mode'\n\nWait\n  seconds: 3\n\nOpen app\n  package: com.example.shop\n\nTap\n  selector: text = 'Retry'\n\nWait for element\n  selector: text = 'Recent orders'\n  timeout: 15s\n```\n\nIf the app queues actions silently, verify the queue instead of expecting an immediate message. For example, after reconnect, open the same order and check that the status changed from `Pending` to `Sent`. Use a canary item in a test environment so you are not touching personal data.\n\n### Recovery edge cases\n\n- If the app restarts after Airplane mode, wait for the home screen again before continuing.\n- If the app shows a cached screen, force a refresh or reopen the section.\n- If recovery depends on a background sync, wait for the synced element rather than a fixed delay.\n\n## Make the flow survive real phones\n\nOEM skins rename and rearrange Quick Settings. Build for variation:\n\n- Prefer `content-desc` or resource ID over visible text when available.\n- Use a condition that accepts both `Airplane mode` and `Aeroplane mode` if your fleet includes UK devices.\n- If Quick Settings is blocked, use a test profile with a debug network toggle, or open Android Settings and navigate to Network & internet, then Airplane mode. Keep that path in a separate sub-flow so one change does not break every flow.\n- Always wait for an element after toggling the network. Radio state changes are not instant.\n- Put the offline toggle and the app recovery steps in reusable sub-flows. That keeps the main smoke flow readable and lets you update the toggle once for the whole suite.\n\n## Run it across a small fleet\n\nStart with one phone, then run the same flow on two or three devices with different Android versions. Phoma can run one flow on many phones, but offline behavior varies by OEM and radio. Record which devices use which selector variant. On your own phones, this is free with no limit on phones or flows; Team and Business plans are for sharing phones and flows inside a team.\n\n## Troubleshooting quick checks\n\n- The Airplane mode tile is missing from the element tree: expand Quick Settings fully, or use the Settings path.\n- The app never shows an offline message: check whether it caches silently. Test the queued action after reconnect.\n- The flow passes offline but fails recovery: increase the settle wait and confirm the online-only element is truly new, not a cached label.\n- The app restarts after Airplane mode: wait for the home screen again before continuing.\n\nThis single pattern gives you a repeatable contract for offline behavior: baseline, cut network, assert, restore, assert recovery. Keep it small, make selectors resilient, and use screenshots as evidence. That is enough to catch the offline regressions that users notice most.\n","https://blog-api.phomaapp.com/api/blog/posts/test-android-app-offline-recovery-phoma/assets",1796464663329]