Android Automation - Getting Started
This section helps you quickly get started with Android Automation. To automate an Android Devices/Simulators using Sahi Pro Classic, refer Android Automation - Getting Started.
Pre-requisites
Section titled “Pre-requisites”- Desktop
- The machine needs to have Android Platform Tools installed so that ADB is available in the system. Having a full blown Android SDK is even better.
- Make sure the path to the Android Platform Tools folder is added to the PATH environment variable. To test this, open a command prompt and type adb (or adb.exe). ADB should start up if the Android Platform Tools folder is in the PATH.
- Device
- Connect the device. Enable USB debugging from Settings -> Developer options.
- To enable Developer options, go to Setting -> About phone -> scroll to Build number and tap it 7 times.
- If you already have the driver for the device installed, you should now be connected through adb. If not, install the USB driver for the device.
- The device has to be connected through USB cable throughout the duration of the test. Alternatively, you can setup adb over Wi-Fi as well if you do not wish to tether the device.
- Screen lock should be removed and display options should be set such that the device does not sleep throughout the execution of the script.
- When the device is connected for the first time, you may get an alert asking for permission to connect. Set it to always accept the connection.
- To know the device ID which is connected to the machine, type
adb devicesin command prompt.
- Connect the device. Enable USB debugging from Settings -> Developer options.
Play Protect Warning
Section titled “Play Protect Warning”On the Android device, Google Play Protect scans for apps that are not known to Play Protect and warns the user during installation.
When running a script on the Android device or connecting to it through the Android Viewer for the first time, Sahi first installs 2 apps on the device to facilitate Android testing. Since these apps are for testing purpose and are not from the Play Store, Google Play Protect can display the following warning.
Warning: Send app for a security check?
Section titled “Warning: Send app for a security check?”
- Click on
Don't sendto dismiss the warning. - You will see a similar warning for the 2nd app -
in.co.sahi.android.test. - Click on
Don't sendagain to dismiss the 2nd warning. The connection will proceed successfully.
To prevent the warning message from appearing again, do the following steps.
-
Open the
Play Storeapp on the device. -
At the top right, tap the
Profileicon. -
Tap
Play Protectfrom the list. -
Play Protectscreen opens. At the top right, tap theSettingsicon. -
The following screen opens.

-
Tap the second option,
Improve harmful app detectionto switch itOFF. The screen now looks like this.
-
Connecting the Android Viewer again or running the script will not show the
Play Protectwarning again.
Download and Install Sahi Pro Mobile Engine
Section titled “Download and Install Sahi Pro Mobile Engine”You need to install Sahi Pro Mobile Engine before you can proceed with the Quick Tutorial
Quick Tutorial
Section titled “Quick Tutorial”Connect Session and Element Identification
Section titled “Connect Session and Element Identification”-
Connect the Android Device to the system.
-
Install the Sample Application
<SAHI_INSTALLATION_FOLDER>/userdata/android/testapps/AndroidApp.apkon the device.- Open a Command Prompt(Windows) or Terminal Shell(Mac, Linux etc.)
- Type
cd <SAHI_INSTALLATION_FOLDER>/userdata/android/testappsand press enter. - Type
adb install AndroidApp.apkand press enter to install the app.
-
Start Sahi Dashboard and click on the
Flowcharts. -
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.

-
Now click on
Connect Sessionbutton. -
This will start
com.sahipro.SahiTestAppapplication in Android device. The device screen is also visible on the Android Viewer.
-
On the Flowcharts window, click on the dropdown arrow next to Launch and then select
Open Controller. You can now start identifying/automating. Like normal Sahi Pro Flowcharts for web pages, you can use CTRL-Hover to identify various elements on the Java Web Start application.
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 a node from the Sahi Pro Flowcharts page, click on the Automate, click on Start Record button, Actions done on the application in 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 Android device.
B. You will need to record these steps explicitly by clicking on ‘Add Step’.

Playback
Section titled “Playback”-
On the
Automatedialog click onRunbutton.
-
The
Run Settingsdialog opens. Select the ModeAndroidand clickRUN.
View Report
Section titled “View Report”-
Click on the
Reportsbutton..
-
The Report opens in a new browser tab.

Further Reading
Section titled “Further Reading”Android Automation in Detail
Android Accessor APIs
Mobile APIs
Working with Multiple Modes in a Single Script

