Block reference / UI Interaction
Element action
Tap, click, long-press, type into, clear, scroll or focus an element.
Only in
WarpX Phone
Element action does one of several things to an element found by its selector. It covers what Touch and Type text do, and adds what only accessibility can: a click that needs no touch, focus, and scrolling the list an element sits in. Reach for it when a touch does not work on an element, or when you want one block whose action you can change later.
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='Order #1042']- Action
Tap, Click (accessibility), Long press, Set text, Clear text, Scroll forward, Scroll back or Focus. The notes say what each does.
ExampleLong press- Text — any languagewhen Action is Set text
The box shown with this placeholder. The text to put in the field, up to 5000 characters; it can hold references.
ExampleLeave at the front door- Add to what the field holdswhen Action is Set text
Off, the field's text is replaced. On, the text is added after it.
ExampleUnchecked- Wait up to (ms)
How long to keep looking for the element before the block fails, in milliseconds. The most is
120000.Example10000- Scroll to find element (times)
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.Example5- 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 the element's text as {{prevBlockData}}. Leaves by its single output.
Example: Open an order's menu with a long press
- Start
- Element action
- Touch
- Pick the phone in the editor's toolbar and open My orders in the shop app.
- Add an Element action block, click Inspect and pick the order's row, then Use in block.
- Set Action to Long press and Scroll to find element (times) to
5, for an order further down the list. - Add a Touch on the menu item that appears, such as Hide order.
- Press Run.
Good to know
- Tap is a real touch at a random point inside the element. Click (accessibility) asks the element, or the nearest clickable one around it, to click, and touches it when nothing will.
- Long press holds for about 0.7 s. For a hold of your own length, use Touch with Touch type Hold.
- Set text and Clear text act on the element, or the first field inside it; an element with no field fails with
It is not a field that takes text. - Scroll forward, Scroll back and Focus act on the nearest element around it that can scroll, or take the focus. When the phone will not do the action, the block fails with
The phone refusedand the action's name. - 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. - When the block fails, it leaves by its fallback output if one is connected: a phone block comes with On error set to Execute fallback. With nothing connected there, the workflow's On workflow error setting decides.
See also
- Touch — Tap, hold or double-tap an element on the phone's screen, or a point on it.
- Type text — Type text into a field on the phone, found by its selector or the one that has the focus.
- Swipe / Scroll — Swipe between two points of the screen, or scroll a list one page.
- Read element — Read an element's text, description, id, position or state, or count how many match.