Appium Bootcamp - Chapter 3: Interrogating Your App

Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted

June 06, 2026 · 11 min read · Tool Comparison

Sauce AI for Test Authoring: Move from intent to execution in minutes.

|

x

Back to Resources

Blog

Posted July 29, 2014

Appium Bootcamp - Chapter 3: Interrogating Your App

quote

[UPDATE- November 2019]You can find the new Get Started with Appium white composition hither:Get Started with Appium- Java and Get Started with Appium- Ruby

This is the third post in a series called Appium Bootcamp by noted Selenium expertDave Haeffner. 

Dave lately bury himself in the open source Appium project and collaborated with leading Appium contributor Matthew Edwards to bring us this material. Appium Bootcamp is for those who are brand new to mobile test automation with Appium. No familiarity with Selenium is required, although it may be useful. This is the third of eight posts; a new post will be relinquish each hebdomad.

Writing automatize scripts to drive an app in Appium is rattling similar to how it & # x27; s done in Selenium. We firstly need to choose a locater, and use it to encounter an element. We can then perform an activity against that constituent. In Appium, there are two coming to question an app to find the best locators to work with. Through the Appium Console, or through an Inspector (e.g., Appium Inspector, uiautomatorviewer, or selendroid inspector). Let & # x27; s pace through how to use each of them to decompose and understand your app.

Using the Appium Console

Assuming you & # x27; ve followed along with the final two posts, you should have everything setup and ready to run. Go ahead and startup your Appium host (by clickLaunchin the Appium GUI) and start the Appium Ruby Console (by goarcin a terminal window that is in the same directory as yourappium.txtfile). After it loads you will see an emulator window of your app that you can interact with as well as an interactive prompt for issuing commands to Appium. The synergistic prompt is where we & # x27; ll want to focus. It offers a host of readily available commands to quickly yield us insight into the factor that make up the user interface of the app. This will help us easily identify the correct locators to automatise our test actions against. The initiatory command you & # x27; ll desire to know about ispage. It gives you access to every factor in the app. If you run it by itself, it will output all of the elements in the app, which can be a bit unwieldy. Alternatively you can delimitate additional arguments along with it. This will filter the output down to just a subset of elements. From thither, there is more information useable that you can use to farther elaborate your results. Let & # x27; s step through some examples of that and more for both iOS and Android.

An iOS Example

To get a spry birds eye view of our iOS app structure, let & # x27; s get a list of the various element classes available. With thepage_classcommand we can do just that.

[1] pry (main) & gt; page_class
get /source
13x UIAStaticText
12x UIATableCell
4x UIAElement
2x UIAWindow
1x UIATableView
1x UIANavigationBar
1x UIAStatusBar
1x UIAApplication

UIAStaticTextand all of the others are the specific family names for types of elements in iOS. You can see reference certification forUIAStaticText here. If you want to see the others, gohere.

With the pagebid we can specify a class gens and see all of the elements for that type. When specifying the element class name, we can either specify it as a string, or a symbolisation (e.g.,& # x27; UIAStaticText & # x27; or: UIAStaticText).

[2] pry (main) & gt; page: UIAStaticText
get /context
post /execute
{
: script = & gt; & quot; UIATarget.localTarget () .frontMostApp () .windows () [0] .getTree () & quot;
}
UIAStaticText
name, label, value: UICatalog
UIAStaticText
name, label: Buttons, Respective uses of UIButton
id: ButtonsTitle = & gt; Buttons
ButtonsExplain = & gt; Respective uses of UIButton
UIAStaticText
name, label: Controls, Various uses of UIControl
id: ControlsExplain = & gt; Various uses of UIControl
ControlsTitle = & gt; Controls
UIAStaticText
name, label: TextFields, Uses of UITextField
id: TextFieldExplain = & gt; Uses of UITextField
TextFieldTitle = & gt; TextFields
...

Note the get and post(only after we supply the bidding but before the element list). It is the meshwork traffic that is happening behind the scenes to get us this info from Appium. The response topost /executehas a script twine. In it we can see which window this element lives in (e.g.,windows () [0]).

This is important because iOS has the concept of window, and some elements may not appear in the console yield yet if they & # x27; re visible to the user in the app. In that case, you could lean the elements in other pages (e.g.,page window: 1). 0is loosely the elements for your app, whereas1is where the system UI lives. This will come in handy when cover with alerts.

Finding Elements

Within each element of the list, notice their place -- thing likenamelabelvalue, and id. This is the kind of information we will want to reference in order interact with the app.

Let & # x27; s take the first element for example.

UIAStaticText
name, label, value: UICatalog

In order to find this ingredient and interact with it, we can can search for it with a twosome of different commands:findtext, or text_exact.

& gt; find (& # x27; UICatalog & # x27;)
...
#
text (& # x27; UICatalog & # x27;)
...
#
text_exact (& # x27; UICatalog & # x27;)
...
#

We & # x27; ll cognise that we successfully found an element when we see aSelenium: :WebDriver: :Elementaim returned.

It & # x27; s worth noting that in the underlying gem that enable this REPL functionality, if we end our command with a semi-colon it will not show us the homecoming object.

& gt; find (& # x27; UICatalog & # x27;)
# presentation returned value

& gt; encounter (& # x27; UICatalog & # x27;);
# return value not displayed

To verify that we hold the element we expect, let & # x27; s access the name property for it.

& gt; find (& # x27; UICatalog & # x27;) .name
...
& quot; UICatalog & quot;

Finding Elements by ID

A better approach to find an element would be to cite its id, since it is less potential to vary than the text of the element.

UIAStaticText
name, label: Buttons, Various role of UIButton
id: ButtonsTitle = & gt; Buttons
ButtonsExplain = & gt; Various uses of UIButton

On this ingredient, there are some IDs we can cite. To find it expend these IDs we can use the id command. And to confirm that it & # x27; s the element we look, we can ask it for its name attribute.

& gt; id (& # x27; ButtonsTitle & # x27;) .name
...
& quot; Buttons, Various uses of UIButton & quot;

For a more thoroughgoing walk through and account of these commands (and some additional ones) gohere. For a full list of available bidding gohere.

An Android Example

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

To get a quick birds eye view of our Android app construction, let & # x27; s get a list of the various element classes useable. With thepage_classdictation we can do only that.

[1] pry (principal) & gt; page_class
get /source
12x android.widget.TextView
1x android.view.View
1x android.widget.ListView
1x android.widget.FrameLayout
1x hierarchy

android.widget.TextViewand all of the others are the specific class names for types of elements in Android. You can see reference documentation forTextView here. If you require to see the others, simply do a Google search for the full class name.

With the pagecommand we can limit a class name and see all of the elements for that type. When specifying the element class name, we can specify it as a string (e.g.,& # x27; android.widget.TextView & # x27;).

[2] pry (main) & gt; page & # x27; android.widget.TextView & # x27;
get /source
post /appium/app/strings

android.widget.TextView (0)
text: API Demos
id: android: id/action_bar_title
strings.xml: activity_sample_code

android.widget.TextView (1)
text, desc: Accessibility
id: android: id/text1

android.widget.TextView (2)
text, desc: Animation
id: android: id/text1
...

Note the get and post(only after we issue the command but before the element listing). It is the meshing traffic that is happen behind the panorama to get us this info from Appium.get /sourceis to download the source codification for the current view andpost /appium/app/stringsgets the app & # x27; s string. These app strings will come in handy presently, since they will be habituate for some of the IDs on our app & # x27; s constituent; which will help us situate them more easy.

Finding Elements

Within each element of the list, notice their properties -- things liketext and id. This is the kind of information we will want to cite in order interact with the app.

Let & # x27; s take the first element for example.

android.widget.TextView (0)
text: API Demos
id: android: id/action_bar_title
strings.xml: activity_sample_code

In order to find that element and interact with it, we can search for it by schoolbook or by id.

& gt; text (& # x27; API Demos & # x27;)
...
#
id (& # x27; android: id/action_bar_title & # x27;)
...
#

We & # x27; ll cognize that we successfully found an element when we see a Selenium: :WebDriver: :Element object returned. It & # x27; s worth noting that in the underlying gem that enables this REPL functionality, if we end our command with a semi-colon it will not demo us the homecoming aim.

& gt; textbook (& # x27; API Demos & # x27;)
# displays returned value

text (& # x27; API Demos & # x27;);
# revert value not expose

To verify we & # x27; ve found the ingredient we anticipate, let & # x27; s access the name attribute for it.

& gt; text (& # x27; API Demos & # x27;) .name
...
& quot; API Demos & quot;

Finding Elements by ID

A best access to find an element would be to cite its ID, since it is less likely to change than the textbook of the element.

In Android, there are a two eccentric of IDs you can search with -- a resource ID, and strings.xml. Resource IDs are best. But strings.xml are a good runner-up.

android.widget.TextView (10)
schoolbook, desc: Text
id: android: id/text1
strings.xml: autocomplete_3_button_7

This element has one of each. Let & # x27; s research using each with the id command.

# resourcefulness ID
id (& # x27; android: id/text1 & # x27;)
...
#

# strings.xml
& gt; id (& # x27; autocomplete_3_button_7 & # x27;)
...
#

You can see a more exhaustive walk through of these commandshere. For a full list of usable commands gohere.

Ending the session

In order to end the console session, input thexbidding. This will cleanly resign thing for you. If a session is not ended decent, so Appium will think it & # x27; s still in progress and cube all next sessions from working. If that occur, then you involve to restart the Appium server by clickingStop and then Launchin the Appium GUI.

xonly works within the console. In our test script, we will usedriver.quitto kill the session.

Using An Inspector

With the Appium Ruby Console up and running, we also have accession to the Appium Inspector. This is another outstanding way to interrogate our app to find locater. Simply click the magnify glass in the top-right hand corner of the Appium GUI (next to theLaunchbutton) to open it. It will load in a new window.

Once it opens, you should see paneling listing the elements in your app. Click on an item in the left-most paneling to drill down into the elements within it. When you do, you should see the screenshot on the right-hand side of the window auto-update with a red highlight around the newly targeted constituent.

You can keep perform this until you find the specific ingredient you want to target. The properties of the ingredient will be outputted in theDetailsbox on the bottom right-hand corner of the window.

It & # x27; s worth noting that while the examiner act well for iOS, there are some problem areas with it in Android at the moment. To that end, the Appium team encourages the use ofuiautomatorviewer(which is an inspector tool render by Google that provides similar functionality to the Appium examiner tool). For more info on how to set that up, readthis.

For older Android devices and apps with webviews, you can use the selendroid inspector. For more information on, gohere.

There & # x27; s loads more functionality available in the inspector, but it & # x27; s outside the scope of this post. For more info I boost you to play around with it and see what you can find out for yourself.

Outro

Now that we cognise how to locate elements in our app, we are ready to discover about automating some simple actions and putting them to use in our first examination.

About Dave Haeffner: Dave is a late Appium convert and the author of Elemental Selenium (a free, once weekly Selenium tip newsletter that is read by thousand of quiz professionals) as easily as The Selenium Guidebook (a step-by-step guidebook on how to use Selenium Successfully). He is also the creator and maintainer ofChemistryKit(an open-source Selenium framework). He has helped numerous companies successfully apply automate acceptance prove; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is a founder and co-organizer of theSelenium Hangoutand has spoken at numerous league and meetups about acceptance testing.

Follow Dave on Twitter -@ tourdedave

Continue the indication the other chapter:

Published:
Jul 29, 2014
Share this post
Copy Share Link
LinkedIn
© 2026 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be file in other jurisdiction.
robot
quote

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free