Block reference / UI Interaction
Touch
Tap, hold or double-tap an element on the phone's screen, or a point on it.
Only in
WarpX Phone
Touch is how a workflow presses things on the phone: a button, a list row, a tab. Point it at an element, picked with Inspect, and it finds the element wherever it is and touches it; point it at coordinates for a game or a screen with no elements to name. For accessibility actions such as a click without a touch, focus or scrolling a list, use Element action; for a picture with no element behind it, Image search.
Settings
- Target
Element (where a new block starts) finds the element named in Selector and touches it. Coordinates touches a fixed point of the screen.
ExampleElement- Coordinateswhen Target is Coordinates
How X and Y are written: Share of the screen (0 – 1), where
0.5,0.5is the middle on any phone, or Pixels of this phone's screen.ExampleShare of the screen (0 – 1)- Xwhen Target is Coordinates
Across, from the left edge. Pick opens the phone's screen in the Inspector: click the point there and Use in block fills X and Y in the block's unit.
Example0.5- Ywhen Target is Coordinates
Down, from the top edge, in the same unit as X.
Example0.82- Touch type
Normal is one tap. Hold keeps the finger down for Hold for (ms), for a long-press menu. Double taps twice on the same place.
ExampleNormal- Hold for (ms)when Touch type is Hold
How long the finger stays down. Choosing Hold fills in
800; the shortest hold is100and the longest10000.Example800- Selectorwhen Target is Element
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.Button[@text='Add to cart']- Wait up to (ms)when Target is Element
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 Target is Element
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.Example3- 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.Example1000,2000
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
With Target on Element, hands on the touched element's text as {{prevBlockData}}. With Coordinates, it hands on nothing. Either way it leaves by its single output.
Example: Add a product to the cart
- Start
- Start app
- Touch
- Pick the phone in the editor's toolbar and open the product's page in the shop app on it, by hand or with a Start app block.
- Add a Touch block and leave Target on Element and Touch type on Normal.
- Click Inspect, pick the Add to cart button on the phone's screen and press Use XPath, or Use in block for a locator that survives app updates.
- Click Verify: it should say
✓ Found: Button "Add to cart". - Set Scroll to find element (times) to
3, in case the button sits below the fold on a smaller phone. - Press Run: the phone scrolls if it needs to and touches the button.
Good to know
- On an element, Normal and Hold touch a random point well inside it, as a finger would, rather than its exact centre. Double taps its centre twice.
- With Share of the screen (0 – 1), X and Y must lie between
0and1, or the block fails naming the field. Shares carry over to phones with other screen sizes; pixels do not. - Coordinates work on any phone that adb can drive. An element target needs the WarpX agent.
- 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. - Verify cannot check a selector that holds a
{{reference}}, since the value is only filled in as the workflow runs. When it finds several elements, the block acts on the first. - A block saved before Touch had a Target runs on its coordinates and opens on that tab.
- 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
- Element action — Tap, click, long-press, type into, clear, scroll or focus an element.
- Type text — Type text into a field on the phone, found by its selector or the one that has the focus.
- Image search — Find a picture on the phone's screen, then tap it, wait for it or say whether it is there.
- Wait for element — Wait until an element shows on the phone's screen, or until it has gone.