Android Automation - Getting Started

abstract 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

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?

To prevent the warning message from appearing again, do the following steps.
  1. Open the Play Store app on the device.
  2. At the top right, tap the Profile icon.
  3. Tap Play Protect from the list.
  4. Play Protect screen opens. At the top right, tap the Settings icon.
  5. The following screen opens.
  6. Tap the second option, Improve harmful app detection to switch it OFF. The screen now looks like this.
  7. Connecting the Android Viewer again or running the script will not show the Play Protect warning again.

Download and Install Sahi Pro Mobile Add-on

You need to install Sahi Pro Mobile Add-on before you can proceed with the Quick Tutorial

Quick Tutorial

Connect Session and Element Identification

  1. Connect the Android Device to the system.
  2. Install the Sample Application <SAHI_INSTALLATION_FOLDER>/userdata/android/testapps/AndroidApp.apk on the device.
    • Open a Command Prompt(Windows) or Terminal Shell(Mac, Linux etc.)
    • Type cd <SAHI_INSTALLATION_FOLDER>/userdata/android/testapps and press enter.
    • Type adb install AndroidApp.apk and press enter to install the app.
  3. Start Sahi Dashboard and click on the Flowcharts.
  4. On the Flowcharts window, click on the dropdown arrow next to Launch and then select Launcher Settings.

  5. Launcher Settings dialog opens.

  6. Description of the image labeling:

    1. Select the Mode: Android
    2. Now select the device from the Device Info dropdown
      Specify Application Package Name:com.sahipro.SahiTestApp

  7. Click on Launch to launch the Application.
  8. This brings up Android Viewer in system's default browser.
  9. Now click on Connect Session button.
  10. This will start com.sahipro.SahiTestApp application in Android device. The device screen is also visible on the Android Viewer.
  11. 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

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.
  • Playback

    1. On the Automate dialog click on Runbutton.
    2. The Run Settings dialog opens. Select the Mode Android and click RUN.
    3. infoWhen the flow is being played back, you CANNOT see the playback happening on the Android Viewer. The Android Viewer does not get refreshed during playback.

    View Report

    1. Click on the Reports button..
    2. The Report opens in a new browser tab.
    infoRefer Run Flowchart for a better understanding.

    Further Reading

    Android Automation in Detail
    Android Accessor APIs
    Mobile APIs
    Working with Multiple Modes in a Single Script