Automating Android Apps - Details
This page describes Android Automation in detail. If you wish to get a quick start, read Android Automation - Getting Started.
Features
Section titled “Features”- Supports running flows against a connected Android device or emulator using SDK 18 and above.
- Android Viewer and Record steps allow easy interaction with the connected device.
- Scripts can be recorded from the Android Viewer and Object spy features are also available.
- Android Inbuilt action syntax is similar to Sahi Pro Inbuilt Actions for browser testing.
- Single Flowchart can interact with different modes like Browser, Desktop, Mobile etc.
Limitations
Section titled “Limitations”- Does not support testing Android device or emulator below SDK 18. (Run
adb shell getprop ro.build.version.sdkto verify) - Does not support run in parallel from the editor, if only one device is connected.
Android Viewer
Section titled “Android Viewer”Android Viewer allows an end user to view the Android device/emulator screen on a Desktop browser. The user can launch the Controller and then identify Android elements by pressing the CTRL key and hovering the mouse over the element.
This section details how to use the Android Viewer.
-
On the Flowcharts window, click on the dropdown arrow next to Launch and then select
Launcher Settings.
-
Launcher Settingsdialog opens.
Description of the image labeling:
- Select the Mode: Android
- Now select the device from the
Device Infodropdown
SpecifyApplication Package Name:com.sahipro.SahiTestApp
-
Click on Launch to launch the Application.
-
This brings up Android Viewer in system’s default browser. If the user wants to launch Android Viewer in a specific browser then, open that Sahi browser and then click on the Android Viewer link from the start page, this brings up Android Viewer in that browser.

-
Device Info:shows the list of the connected device to the systemApplication Package Name:allows an end user to start an application by it’s package name which is already installed in that device. Leave it blank if you want to start the device session in its current state of the screen. -
Make sure that the device is connected through a USB cable or over Wi-Fi. Click on
Connect Session. If the connection is successful, you will see the device screenshot in a short while.
-
When some action is performed from the Android Viewer, the screenshot will be refreshed a few times, to display the latest device state. However, if actions are performed on the device manually, the screenshot will not get refreshed. Click on the
Refreshicon manually to refresh the screenshot. -
One can interact with the device from the Android Viewer itself without launching the Controller.
-
Launch the Controller by ALT and Double clicking on the android device.
-
You can now start identifying elements by pressing the CTRL key and hovering the mouse over elements on the Desktop screenshot. You will notice the Accessor textbox on the Controller, showing the accessor for the element. The dropdown displays the alternatives for the accessor.

Android Viewer Actions:
Section titled “Android Viewer Actions:”
These buttons perform various actions on the Android device and these actions are recorded while Record a steps. These will give quick access to Android assist functions during debugging/script recording.
-

is used to swipe up on the screen.
-

is used to swipe down on the screen.
-

is used to swipe left on the screen.
-

is used to swipe right on the screen.
-

is used to call up the menu of the app on the display.
-

will press enter in the text field.
-

is used to open search field (if present) within an application.
-

will show all recent open apps.
-

is used for navigating to the home screen.
-

simulates the back action.
Screenshot Outline View
Section titled “Screenshot Outline View”Security restrictions may prohibit Android Viewer from capturing the screen shot to be displayed. In such a case, you can use the Screenshot Outline View feature to toggle the outline view.
For example, let’s assume that for the below screen, Android Viewer is unable to take the screenshot. To enable the outline view, check the highlighted checkbox in Android Viewer.

After checking it, the Android Viewer will display the outline view like this.

Now you will be able to identify the elements in controller.
Configure Android Devices/Emulators
Section titled “Configure Android Devices/Emulators”-
Click All Settings on the Dashboard. The All Settings window opens.
-
Click Sahi Pro Settings. The Sahi Pro Settings page opens.

In the menu on the left, open Browsers And Devices and click Android Device Definitions (android_devices.xml).

androidDevice Node
Section titled “androidDevice Node”<androidDevices> <!-- Moto device with 2 capacity -->
<androidDevice> <name>Moto</name> <displayName>Moto G5</displayName> <deviceId>XXXX</deviceId> <deviceId>YYYY</deviceId> </androidDevice></androidDevices>| Element | Value |
| name | Key by which this androidDevice will be referred. This can be any value without spaces. |
| displayName | Better name displayed in Android Viewer. |
| deviceId | Id of the device, multiple Id can be added under same name. you can get the Device Id by executing this command |
Automating a Keyword
Section titled “Automating a Keyword”This is similar to automating a Sahi Pro Flowcharts keyword for normal browser testing.- To automate a Keyword, click on the Keyword from the Sahi Pro Flowcharts page, click on the Automate, click on Start Record button, Actions done on the application on Android device are recorded automatically.
-
Steps can also be recorded from the Flowcharts Controller.
-
A. You can use Click, Set, Assert, choose ‘Other Actions’ to perform an action on the Windows Desktop Application.
B. You will need to record these steps explicitly by clicking on ‘Add Step’.

Automating Hybrid App
Section titled “Automating Hybrid App”Pre-requisites
Section titled “Pre-requisites”- Android Device must be connected on the same network in which Sahi Pro is running.
- Configure the proxy in Android Device.
For recording Android application which contains Webview (Hybrid content), open the application in Android Viewer and go to the screen which contains webview.
If the screen is displaying hybrid contents then there will be one checkbox labeled Enable web view identification.
-
Check the checkbox to identify/record hybrid elements as Web.
-
Press the CTRL key and mouse over the hybrid element.
-
Element’s accessor will be displayed in Flowchart Controller.

-
To automate the hybrid app, perform the actions directly from Android Device.
Playback
Section titled “Playback”-
On the
Automatedialog click onRunbutton.
-
The
Run Settingsdialog opens. Select the ModeAndroidif we did not mentioned in the scipt and clickRUN.

