Skip to content

[Test Automation] A beginner's guide to writing automated UI test suites in Python for Android mobile apps using Appium.

Notifications You must be signed in to change notification settings

k-chuang/android-ui-test-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Appium Mobile UI Test Automation

This project is just a basic outline on how to set up appium, an open source test automation framework for native, mobile web, and hybrid applications, and use it to run automated UI tests for Android apps.

Appium is cross-platform, and supports a lot of mobile platforms (iOS mobile, Android mobile) as well as mobile web applications (Safari on iOS, Chrome on Android).

In this project, I will be using open source APKs to write simple tests to familiarize myself with the Appium test framework.

Setup

  1. Install Java JDK
  • Using the SDK Manager, you can:
    • Install all the necessary packages, Android versions, etc.
    • (Optional) Install adb in the 'Extras' tab
      • Only do this if you want to test a physical device, otherwise, you do not need to do this step, since you can run emulators to emulate Android or iOS devices.
  1. Set JAVA_HOME in environment variables, and reference it in PATH environment variable.
  • For Windows:
    • from control panel, edit environment variables window and add the following
    JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
    PATH = C:\Program Files\Java\jdk1.8.0_45\bin;
  • For MacOS:
    • in your ~/.bash_profile
    export JAVA_HOME= '/usr/libexec/java_home'
    export PATH = $PATH:$JAVA_HOME/bin
  1. Install Android SDK
  • Use SDK Manager to install necessary packages, such as Android SDK Build Tool, Android versions and their APIs, etc.
  1. Set ANDROID_HOME in environment variables, and reference it in PATH environment variable.
  • See step 2 for a similar reference.
  1. Install appium via 2 ways:

Procedure

Here is a high level summary of the procedure of how to use Appium for UI test automation via an emulator and a physical Android device.

  1. Open Appium Desktop application, and set the appropriate host IP address, and port number.
  2. Physical Device:
  • Connect the physical phone to your laptop/PC, and enable 'Developer Options'
  • Run 'adb devices' in the shell to double check that it is properly connected
  • This step is necessary to do for programmatic interaction via adb
  • When setting desired capabilities, set deviceName to the adb device number of your physical device.
    • Find this device number by typing 'adb devices' in the terminal
  1. Android Emulator:
  • Using Android Studio or command line utility (avdmanager), create a virtual device.
  • When setting desired capabilities, set deviceName to avdname of your emulator
    • Find the avdname by typing 'emulator -list-avds' in the terminal
  1. Install the Appium Client Python library via:
pip install Appium-Python-Client
  1. Start coding in Python!
  • Used unittest to write test cases and test suite
  • Used pytest as the test runner to execute the test suite
  1. Used UI Automator Viewer to view elements of the Android app and incorporate within code.

UI Functional Testing

I decided to test an open source recording app called SoundRecorder for practice.

The apk is located here.

I will include more tests on different Android apps in this repo as time progresses.

About

[Test Automation] A beginner's guide to writing automated UI test suites in Python for Android mobile apps using Appium.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages