May 15, 2017

Build a Basic Appium Framework: Review How to Inspect Mobile Apps with Appium Desktop

For this next blog series, we will be building a basic Appium Framework built on top of the information gathered in the Learning Appium Desktop series. This basic mobile automation test framework we will be constructing will consist of:

  • Appium Desktop: To investigate the app we will be writing automated tests for, and to start up an Appium server on our local machine. ( Official GitHub site
  • An Android Emulator: Created by Android Studio and the Android Virtual Machine (AVM) Manager, connected to your local computer with the Android Debug Bridge ("adb"). ( Official Developer.Android.Com site on emulators )
  • The code will be written in the Java Client version of Appium using a MacBook and IntelliJ as an Integrated Development Environment (IDE). Although Android Studio, IntelliJ, and Android .apk files run on both Windows and Macs, the next version of this project will consist of emulated iPhones, iPads and Apple .ipa files use XCode, which (as far as I know) doesn't work on Windows machines. ( Official Github for appium/java-client )
  • Tests will be kicked off using TestNG. I like the annotations and the built in ability to have parallel tests running. We won't explore it in this particular series, but we will later. ( See the official TestNG site ).  
  • It will use Hamcrest, a Java matcher program in order to create very readable tests. (Official site for )
I will be attempting to finish code walkthrough over the next two weeks on a Monday / Wednesday / Friday publishing schedule.

Want to get to the good stuff? I already have the code all written that we will be exploring! You can access it at

Please feel free to use any IDE you wish to code in: vim, emacs, nano, Sublime Text Editor, IntelliJ or Eclipse. You could even use Android Studio, built on top of IntelliJ. I prefer IntelliJ IDEA, first introduced to it when I was working through Alan Richardson's Selenium WebDriver with Java course back in 2013.

Disclaimer: Coding in Appium is still brand-new to me. I only first started a month ago, slowly working my way through two online courses. Learning Appium Desktop, the initial setup, took so much longer than I thought it was going to!

Because it was so complex, even though we just covered all this content month ago, you might need a review... I sure did! Last week, when I was ramping up a co-worker on setting up Appium Desktop on his machine ("Hi, Rahul!") I had to refer back to the notes on my blog many, many times.

Review: How Do I Inspect Mobile Apps on Appium Desktop, Again? 

If you have never set up Appium Desktop before, I suggest you go through my notes on Learning Appium. It's tricky! My notes should spell it all out for you. Here are seven steps to get yourself up and running, referring back to the notes.

Step 1:  Install Java, if need be, and install and launch Appium Desktop

Behold, the Appium Desktop start screen lives again!

... Then, start a new Server by pressing the "Start Server v.16.4-beta" button. Let's leave the host at (your local host, Home) and the port at 4723 for now.

Appium is running in the background, listening for commands to be sent to

Step 2:  Install Android Studio, which comes with the both Android Software Development Kit (SDK), and Android Command Line Tools such as the Android Debug Bridge (ADB) to connect your physical Android device via USB. Make sure to set up ANDROID_HOME!

Step 3: Connect your physical Android device via WiFi, if you wish. This project will use Android emulators, but physical devices will work, too.

Step 4: Set up an Android emulator using Android Studio’s AVD (Android Virtual Device) Manager. Run the emulator.

Step 5: Find the appPackage and appActivity for the App: Install the .apk you will be testing against by downloading the .apk, then dragging and dropping the .apk onto an Android emulator to install it. Me, I will be using ApiDemos-debug.apk for this chapter.

  • Go to Appium's Java-Client page.
  • Right-click on ApiDemos-debug.apk and select "Save Link As". Save it onto your Desktop.
  • Drag-and-drop it from your Desktop, your Download folder, or wherever you saved it, onto your running emulator. 
  • Double-click the "ApiDemos" folder to launch the program on the emulator. 

The ApiDemos-debug.apk app we will be automating.

While the app is running:

  • Open your Mac Terminal. 
  • Copy-and-paste the following code into your Mac Terminal.

 adb shell "dumpsys window windows | grep -E 'mCurrentFocus | mFocusedApp'"  

... This code uses the Android Debug Bridge to go into the app running, and grab either the currentFocus or FocusedApp, and dump the output.

This showed me:

 mFocusedApp=AppWindowToken{2693b97 token=Token{ec7ff31 
ActivityRecord{10a4fd8 u0 t254}}}  

Step 6:  Enter the Desired Capabilities, save the Capability Set

  • Going back to Appium Desktop, select "Start New Session". 
  • Fill out the Desired Capabilities

platformName: Android

deviceName: emulator-5554


appActivity: .ApiDemos

  • Select the "Save As..." button, and save it as something such as "ApiDemos".
... When we finally run automated tests, setting up Desired Capabilities, we will find that instead of appPackage, and appActivity, we can just use the appName. If we did that with Appium Desktop, like I did in my first attempt, I would be hit by a known bug in one of the Android Command Line Tools and it would not work.

Step 7: Press the Start Session button. Three horizontal panels will appear.

Now that Appium Desktop is up and running, Inspect away!

Left panel: A reflection of the app or virtual device
Middle panel: The app source, much like the DOM of a web page.
Right Panel: The properties of the selected element.

For example, if we select the API Demos area on the first screen that pops up, you can see that:

  • ID: android:id/action_bar

Now that we have Appium Desktop and an Android emulator up and running, tomorrow we will be inspecting the mobile elements of this app and designing a basic test.

Stop by tomorrow, and we can examine the app to see what we can do for a basic test...

-T.J. Maher
Twitter | LinkedIn | GitHub

// Sr. QA Engineer, Software Engineer in Test, Software Tester since 1996.
// Contributing Writer for TechBeacon.
// "Looking to move away from manual QA? Follow Adventures in Automation on Facebook!"


saivenkat said...

It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
Help Desk app

vé máy bay từ canada về việt nam said...

Mua vé máy bay tại Aivivu, tham khảo

vé máy bay đi Mỹ giá rẻ

bay từ california về việt nam mất bao lâu

đăng ký bay từ canada về Việt Nam

lịch bay từ nhật về việt nam hôm nay

Máy bay từ Hàn Quốc về Việt Nam

Vé máy bay từ Đài Loan về VN

chi phi ve may bay cho chuyen gia nuoc ngoai

LasseNielsen said...

I used a few times only for Italian transcriptions from recordings. The quality of the work is way superior to other transcription agencies that I dealt with in the past. The accuracy to the spoken recording provided by me, and the amazing ability to separate voices in a group, or even voices which are no more than a murmur, are absolutely amazing. And I have to say the same about the professionalism of typingservice personnel.