Inspecting Ui elements using Appium desktop

Dedicated inspection session

Appium Desktop has a functionality to do inspection of the UI elements. If test developer has the application package (APK) available, then also Android Studio can be used for this. In this example, Appium Desktop Windows is used. Please note that Appium Desktop inspection works also with Mac.

  1. Connect Android device which is in developer mode to the Windows computer using USB cable. Allow access and trust/authorize the device. Open command prompt and type command:

adb devices
cmd adb devices











  1. Start Appium Desktop (NOTE: the name is Appium when you search the programs)

start appium









  1. When UI starts, then click Start Server button

start server









  1. Click File → New Session Window…

  1. Select Automatic Server tab, if not selected. If you have manually started Appium Server, then use Custom Server tab

automatic server
  1. Next fill out Desired Capabilities. Below is an example JSON which launches Home screen on Android 6.0. You can click pen icon on JSON Representation text box and copy paste JSON there and save it.

{
  "appPackage": "com.sec.android.app.launcher",
  "appActivity": "com.sec.android.app.launcher.activities.LauncherActivity",
  "noReset": true,
  "fullReset": false,
  "automationName": "UIAutomator2",
  "deviceName": "Samsung Galaxy S8",
  "platformName": "android"
}
  1. When capabilities are entered and no complaints, then click Start Session button

  1. After a while when session is established and you should see the device screen, app source and selected element views on the computer’s screen:

device screen
  1. Now, you can either operate device directly or by using the Appium. If you operate device directly then remember to refresh the Appium view by clicking top Refresh Source & Screenshot button. Here Play Store is clicked on the device directly and then refreshed the view:

play store
  1. If you click any of the elements with mouse cursor on the computer, then the element details will be shown on the right-side view:

element details





















Inspecting existing session

In certain scenarios it might be useful to pause test execution to a specific point and start inspecting the UI elements. This can be achieved by pausing the execution by using Debug keyword and then Attach to Session… feature in Appium Desktop.

  1. Import library called DebugLibrary in the test suite which you wish to inspect:

*** Settings ***
Library    QMobile
Library    DebugLibrary
  1. Set argument newCommandTimeout to 0 or big enough number so that Appium will not timeout the session:

*** Variables ***
${newCommandTimeout}    0
  1. Add Debug keyword as a new test step to the test case which execution you wish to pause:

*** Test Cases ***
Verify Text in TextView
    [Tags]       VerifyText
    AppState     API Demos Home
    Debug
    VerifyText   Accessibility
  1. Execute the suite (or just the test case). When Debug keyword is executed then RF debugger is invoked:

==============================================================================
Text Config
==============================================================================
Verify Text in TextView                                               ..
>>>>> Enter interactive shell
Only accepted plain text format keyword separated with two or more spaces.
Type "help" for more information.
>
  1. In the Appium session windows click tab Attach to Session…

  1. Select the existing session from the drop down. Use the refresh button on the right-side, if session is not visible.

attach to session button
  1. Click Attach to Session

attach to session













  1. You can either enter more QWords in RF debugger, click the device directly or use the inspector commands. To continue the test execution, write Exit to debugger. Execution will continue from the next test step after Debug keyword.