Basic Appium Automation: Part 5 — Entering Text & Tapping Buttons
An introduction to entering text, clearing text and clicking mobile buttons in Appium.
In previous parts of this series, we looked at Appium locators (finding an element), and glossed over on how to interact with these elements. In this next part of the series, I’ll go over some more detail on interacting with different common elements (such as text fields, buttons, switches, sliders, drop down boxes, etc.).
Let’s start with the simple ones first! This exercise will cover text fields, typing and buttons.
Enter Text into Text Field
Text fields are extremely common, and the way to enter field into text fields is the same for iOS and Android — send_keys
. For this example, I will use the iOS TestApp’s text box, but this is exactly the same for Android.
After clicking on the first text box in Appium Inspector, we can get three candidate properties for locating this element:
- Accessibility ID —
IntegerA
- Name —
IntegerA
- XPath —
//XCUIElementTypeTextField[@name="IntegerA"]
As a general rule, we prefer “accessibility id” or “name”. While XPath is more flexible, it can…