[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"blog-post-en-handle-pop-ups-loading-screens-phoma-flows":3},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":15,"thumbnail_url":16,"translations":17,"body":18,"asset_base":19},"handle-pop-ups-loading-screens-phoma-flows","en","Handle Pop-Ups and Loading Screens in Phoma Flows","Make your Phoma flows reliable by waiting for elements, handling pop-ups, and branching on screen text instead of fixed delays.","2026-11-08",[10,11,12,13,14],"phoma","android","automation","qa","flows",[10,11,12,13,14],"https://blog-api.phomaapp.com/api/blog/posts/handle-pop-ups-loading-screens-phoma-flows/thumbnail.svg?lang=en",[5],"## Why Fixed Delays Break Android Flows\n\nAndroid apps rarely load on a predictable schedule. A network call can finish in one second or ten. A system dialog can appear over your target button. A spinner can linger after the screen looks ready. If your Phoma flow uses a fixed wait—pause two seconds, then tap—it will tap too early on a slow device and too late on a fast one, or it will tap the wrong thing when a pop-up steals focus.\n\nPhoma runs flows visually on your own Windows PC and Android phones, with no code required. Phoma’s AI flow builder is optional and runs on your own AI key or subscription; this guide covers the visual builder steps directly. Because every step acts on a real element tree, the most reliable way to build a flow is to wait for the element you actually need, not for a timer to expire. This guide shows how to use Phoma’s Wait for Element step, conditional branches, and loops to handle pop-ups, loading screens, and other interruptions so your flows run the same way every day, on one phone or many.\n\n## Start with the Right Selector\n\nBefore you can wait for an element, Phoma must be able to find it. Open your phone’s screen in Phoma’s viewer, inspect the element tree, and pick a selector that survives app updates.\n\nPrefer these in order:\n\n1. `resource-id` — the internal ID assigned by the developer. It rarely changes between releases.\n2. `content-desc` — the accessibility label. Stable when the app supports accessibility, but verify it after updates.\n3. `text` — visible button or label text. Easy to read, but changes if the app is localized or copy is edited.\n\nAvoid selectors that depend on screen position or on text inside a long sentence, because those break when layout shifts.\n\nExample selectors you might paste into Phoma’s step editor:\n\n```\nresource-id: com.example.warehouse:id/scan_button\ncontent-desc: \"Update available\"\ntext: \"Sync complete\"\n```\n\n## The Wait for Element Step\n\nAdd a Wait for Element step immediately before any tap, type, or read-text step that depends on a screen appearing.\n\nConfigure three things:\n\n- **Selector** — the element you expect.\n- **State** — whether you are waiting for the element to appear, or to disappear. Use “disappear” for loading spinners, progress bars, or “Updating…” overlays.\n- **Timeout** — how long Phoma should keep checking before giving up. Start with 15 to 30 seconds for network-dependent screens. If the element appears faster, Phoma proceeds immediately; it does not sleep for the full timeout.\n\nWhy this matters: a fixed delay assumes the slowest possible device every time. A wait step adapts to actual device speed, so a fast phone does not waste time and a slow phone does not fail.\n\n### Real-world flow: morning stock check\n\nImagine a warehouse app that your team uses to confirm overnight stock counts. The flow looks like this in Phoma:\n\n1. **Open app** — `com.example.warehouse`\n2. **Wait for element** — `resource-id: com.example.warehouse:id/spinner`, state: disappear, timeout: 30s\n3. **Tap** — `text: \"Stock Count\"`\n4. **Wait for element** — `resource-id: com.example.warehouse:id/list_loaded`, state: appear, timeout: 20s\n5. **Read text** — `resource-id: com.example.warehouse:id/count_value`, save to variable `morning_count`\n6. **Tap** — `text: \"Submit\"`\n\nIf step 2 times out, the app may be stuck on a loading screen. Phoma stops the flow at that step instead of tapping a button that is hidden behind a spinner.\n\n## Handle Pop-Ups with Conditional Branches\n\nPop-ups are the most common reason flows fail. An app update, a login prompt, or a “Continue in beta?” dialog can appear between any two steps.\n\nUse Phoma’s condition step to branch based on whether an element exists:\n\n- **If element exists** — `content-desc: \"Update available\"` → tap “Remind me later,” then continue.\n- **Else** — proceed to the next intended step.\n\nThis keeps the flow on the happy path when the dialog is absent, and clears it when it appears. You can stack conditions for multiple likely interruptions, but keep the list short. Too many branches make the flow hard to debug.\n\n### Example: conditional update dialog\n\n```\nCondition: content-desc \"Update available\" exists?\n  Yes:\n    Tap text \"Remind me later\"\n    Wait for element text \"Dashboard\" appear\n  No:\n    Continue to next step\n```\n\n## Use Loops for Unreliable Appearances\n\nSometimes an element appears after a retry, not immediately. Instead of one long wait, use a loop:\n\n1. Wait up to 5 seconds for the element.\n2. If not found, tap “Refresh” or pull to refresh.\n3. Repeat up to 3 times.\n4. If still not found, fail the flow and take a screenshot.\n\nThis pattern works well for screens that depend on background sync or Bluetooth device discovery, where the UI updates in pulses rather than all at once.\n\n## Capture Screenshots at Decision Points\n\nAdd a screenshot step after every conditional branch and before any final submission. Screenshots do not replace assertions, but they give you evidence when a flow fails on a phone you are not holding.\n\nName screenshots descriptively inside Phoma so you can tell later whether the failure happened at the login pop-up or at the submit button. If you share phones and flows with a team through a Team or Business plan, screenshots become part of the run history that teammates can review.\n\n## Optional: Send Results with an HTTP Request\n\nPhoma includes an HTTP request step for sending flow results to an endpoint you control. Because flows run on your own computer and phones, the request originates from your network. A common use is posting a completion webhook after a daily stock count, or logging a failure to a channel your team monitors.\n\nKeep the payload small. Send the phone name, flow name, status, and the captured variable—never personal data, passwords, or credentials extracted from the app.\n\n## Running the Same Flow on Many Phones\n\nOnce the flow is stable on one device, you can run it on multiple phones at once from Phoma. Each phone executes the flow independently using its own selectors and timeouts. If one phone is on an older Android version and an element renders differently, inspect that phone’s tree and adjust the selector for that device only; you do not need to rewrite the whole flow.\n\nScheduling works while the app is open. Set the run time, choose the phones, and let Phoma execute. Because everything runs locally on your Windows machine and Android devices, there are no per-phone limits on the free plan.\n\n## Troubleshooting Checklist\n\nIf a wait step times out, check these in order:\n\n- Is the selector visible in Phoma’s element tree right now? If not, the app may be on a different screen than expected.\n- Is an overlay, keyboard, or system dialog covering the element? Use a condition to dismiss it first.\n- Did the app update and change the `resource-id`? Re-inspect and update the selector.\n- Is the phone screen off or locked? Unlock and keep the screen on during the run.\n- Is the timeout too short for a slow network? Increase it in 10-second increments.\n\n## Keep Flows Maintainable\n\nName every step after the business action, not the technical control. “Tap Submit stock count” is easier to review than “Tap button 4.” Group related steps with comments if Phoma supports them in your version, and document which selectors belong to which app version.\n\nWhen an app update breaks a flow, you usually only need to replace one selector, not rebuild the flow. That is the advantage of waiting for elements instead of guessing when they will appear.\n","https://blog-api.phomaapp.com/api/blog/posts/handle-pop-ups-loading-screens-phoma-flows/assets",1796035641843]