Test Android App Offline and Recovery Behavior with Phoma
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.
Why test offline and recovery as one flow
Testers 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:
- The app shows a clear offline state instead of crashing or spinning forever.
- Any action that needs the network fails gracefully and does not corrupt local state.
- When the network returns, the app recovers, retries, or tells the user what to do.
Combining 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.
Before you build the flow
Use a dedicated test phone or a clean test profile. You need:
- A build with a known offline screen, such as a text label
No internet connectionor a retry button. - Quick Settings access on the phone. Some device policies hide it, so confirm this first.
- A selector for the Airplane mode tile. On many phones it is exposed as
content-desc = 'Airplane mode'; on others it may betext = 'Airplane mode'or a resource ID. - A stable app screen selector after launch, such as
content-desc = 'Home'ortext = 'Shop'.
Do not rely on fixed sleeps for app readiness. Use a short settle wait only for the network change, then wait for an element.
What to confirm first
Open 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.
Step 1: Open the app and confirm the online baseline
Start 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.
- Open the app.
- Wait for the home screen element.
- Tap the section that will be used later, such as Orders.
- Wait for a known online-only element, such as
text = 'Recent orders'. - Take a screenshot as a baseline checkpoint.
If this fails, fix selectors or app state before adding offline steps. A flow that cannot find the online state will produce misleading offline failures.
Step 2: Turn on Airplane mode from Quick Settings
Use the phone's own Quick Settings rather than a system setting path that changes between manufacturers.
- Swipe down from the top of the screen twice to expand Quick Settings.
- Tap the Airplane mode tile.
- Wait about two seconds for the radio to settle.
- Open or return to the app.
- Trigger the network-dependent action, such as tapping Refresh or opening Orders.
Illustrative Phoma steps:
Swipe
direction: down
times: 2
Tap
selector: content-desc = 'Airplane mode'
Wait
seconds: 2
Open app
package: com.example.shop
Tap
selector: text = 'Orders'
Wait for element
selector: text = 'No internet connection'
timeout: 10s
The 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.
If Quick Settings is blocked
Some 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.
Step 3: Assert the offline state and capture evidence
After the offline action, read the text on screen and use a condition.
- If the text contains
No internet connection,Offline, or your app's equivalent, mark the step as passed. - If the expected text is missing, take a screenshot and fail the flow with a clear message.
- If the app shows a retry button instead of text, wait for that button and assert its presence.
Example condition logic:
Read text
selector: text = 'No internet connection'
store as: offlineMessage
Condition
if offlineMessage contains 'No internet'
pass
else
screenshot: offline-failure.png
fail: expected offline message
Screenshot 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.
Step 4: Restore the network and verify recovery
Recovery is the half most teams skip. The flow should prove the app notices the network is back.
- Swipe down twice to open Quick Settings.
- Tap Airplane mode again to turn it off.
- Wait about three seconds for the network to reconnect.
- Open the app.
- Tap Retry, Refresh, or the same Orders action.
- Wait for the online-only element from the baseline, such as
text = 'Recent orders'. - Read a status text if the app shows one, such as
Connection restored. - Take a final screenshot.
Tap
selector: content-desc = 'Airplane mode'
Wait
seconds: 3
Open app
package: com.example.shop
Tap
selector: text = 'Retry'
Wait for element
selector: text = 'Recent orders'
timeout: 15s
If 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.
Recovery edge cases
- If the app restarts after Airplane mode, wait for the home screen again before continuing.
- If the app shows a cached screen, force a refresh or reopen the section.
- If recovery depends on a background sync, wait for the synced element rather than a fixed delay.
Make the flow survive real phones
OEM skins rename and rearrange Quick Settings. Build for variation:
- Prefer
content-descor resource ID over visible text when available. - Use a condition that accepts both
Airplane modeandAeroplane modeif your fleet includes UK devices. - 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.
- Always wait for an element after toggling the network. Radio state changes are not instant.
- 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.
Run it across a small fleet
Start 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.
Troubleshooting quick checks
- The Airplane mode tile is missing from the element tree: expand Quick Settings fully, or use the Settings path.
- The app never shows an offline message: check whether it caches silently. Test the queued action after reconnect.
- The flow passes offline but fails recovery: increase the settle wait and confirm the online-only element is truly new, not a cached label.
- The app restarts after Airplane mode: wait for the home screen again before continuing.
This 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.
