Block reference / UI Interaction
Clear text
Empty a text field on the phone.
Only in
WarpX Phone
Clear text empties a field: a search box that still holds the last search, a form an app filled in for you, a field before you type something new into it. Type text with Target on Element already replaces a field's text, so Clear text is for when you want the field empty, or before typing into it with Focused field.
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. The element can be the field itself or something around it: the first field inside it is cleared.Example//android.widget.EditText[@resource-id='com.example.shop:id/search_box']- 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.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 nothing. Leaves by its single output.
Example: Search for each keyword in a list
- Start
- Loop data
- Clear text
- Touch
- Type text
- Press key
- Loop breakpoint
- Add a Loop data block with Loop ID
keywordsover your list of search terms. - Add a Clear text block, click Inspect and pick the search box, then Use in block.
- Add a Touch on the search box, a Type text with Target on Focused field and the text
{{loopData.keywords}}, and a Press key with Keyenter. - Close the loop with a Loop breakpoint and press Run.
Good to know
- 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. - If the element holds no field that takes text, the block fails with
It is not a field that takes text. - 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
- Type text — Type text into a field on the phone, found by its selector or the one that has the focus.
- Element action — Tap, click, long-press, type into, clear, scroll or focus an element.
- Touch — Tap, hold or double-tap an element on the phone's screen, or a point on it.