Block reference / UI Interaction
Wait for element
Wait until an element shows on the phone's screen, or until it has gone.
Only in
WarpX Phone
Wait for element holds the run until the screen is ready: until a page has loaded, a spinner has gone or a confirmation has appeared. It is woken by the screen changing, so it carries on as soon as the element is there rather than after a fixed pause. Use it instead of a Delay wherever you can name what you are waiting for.
Settings
- Selector
The element to act on. Inspect opens the Inspector for the phone picked in the editor's toolbar: pick the element, then Use in block for its locator, which still finds the element after the app changes, or Use XPath. You can also write an XPath such as
//android.widget.Button[@text='Sign in'], or plain text, which means the element whose text is exactly that; Verify looks for it on the phone now and says whether it found one, several or none.Example//android.widget.TextView[@text='My orders']- Wait until it
shows waits for the element to appear; is gone waits for it to leave the screen, such as a loading spinner.
Exampleshows- Fail when the time runs out
On (the default), the block fails when Wait up to (ms) runs out. Off, it goes on either way, and the variable says which happened.
ExampleChecked- Save whether it happened (true / false) to a variable
Also stores the answer,
trueorfalse, in a workflow variable.ExampleChecked- Variable namewhen Save whether it happened (true / false) to a variable is on
The variable to write. Later blocks read it as
{{variables.signedIn}}, for example in a Conditions path.ExamplesignedIn- Wait up to (ms)
How long to wait, in milliseconds, up to
120000. The default is10000.Example15000- Scroll to find element (times)when Wait until it is shows
When the element is not on screen, scroll the screen's main list and look again, up to this many times (at most
50).0does not scroll. It stops early when the list cannot move any further.Example0- Delay (ms)
A pause after the block finishes, before the next block starts. Write one number such as
1000, or a range such as1000,3000for a random pause in that range on each run.Example0
Every block also has the shared block settings — a description, Disable block and what to do on an error, and Finding elements on a phone explains selectors, Inspect and Verify in more depth. Fields that take text accept data from earlier blocks.
What it hands on
Hands on true when the element showed (or went) in time and false when it did not, as {{prevBlockData}} and in the variable when asked. Leaves by its single output, unless it fails.
Example: Wait for the account page after signing in
- Start
- Start app
- Type text
- Type text
- Touch
- Wait for element
- Conditions
- Pick the phone in the editor's toolbar. Build the sign-in steps with Type text and a Touch on Sign in.
- Add a Wait for element block, click Inspect and pick My orders on the account page, then Use in block.
- Leave Wait until it on shows, set Wait up to (ms) to
15000, and untick Fail when the time runs out. - Tick Save whether it happened (true / false) to a variable with the name
signedIn, and branch on it with Conditions. - Press Run.
Good to know
- The failure says
The element did not show before the time ran out, or for is gone,The element was still on the screen when the time ran out. - is gone is decided by one selector: with a locator from Use in block, the first of its selectors is used.
- Element blocks read the screen through the WarpX agent, which the Devices page installs on the phone. Without it the block fails with
AGENT_NOT_INSTALLED. - What Selector accepts: anything starting with
/or(/is an XPath, evaluated as full XPath 1.0 over the screen's elements with the attributes Appium uses (text,resource-id,content-desc,class,package,boundsand flags such asclickable), socontains()andstarts-with()work. Text starting with{or[is read as JSON: the locator Use in block writes, or a selector such as{"res": "com.example.shop:id/search_box"}. Anything else is the exact, case-sensitive text of an element. There is notext=orid=shorthand:text=Sign inlooks for an element whose text istext=Sign in.
See also
- Element exists — Whether an element is on the phone's screen: true or false.
- Find text (dump) — Look for text among the screen's elements, and say whether it is there or tap it.
- Touch — Tap, hold or double-tap an element on the phone's screen, or a point on it.