Instruction for software installation, necessary for Android applications testing

    This is a step-by-step instruction for software installation, necessary for Android applications testing on a real device or on an emulator of Android applications (AVD).

    Installation and configuration of Appium

    Appium is an instrument for automatization of mobile applications, using Webdriver API. It represents an HTTP server, developed using NodeJS, which creates and processes WebDriver sessions. In its work Appium follows the same approach as Selenium WebDriver, which receives HTTP requests from clients in JSON format and transforms them depending on platform it works on.

    Appium, perhaps, is one of the most famous instruments for mobile applications testing. The basic Appium principles:

    • For automated application testing a user doesn’t need to recompile it or modify it somehow.
    • A user doesn’t have to be tied to a specific programming language for tests writing.
    • No need to reinvent the wheel when it comes to automating API testing.
    • The framework for mobile automated testing should be open source, not only in name but also in spirit.

    Using of these four principles give the main opportunities to Appium:

    • Free, open source platform with open code.
    • Contains a framework or interface, that transfers Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands depending on the type of device, but not on the type of OS. That means there is no dependence on the type of OS of a mobile device.
    • It supports the main programming languages: Java, Python, JavaScript, PHP, C# and Ruby.
    • It supports automated testing of native, mobile and hybrid applications on real devices, as well as on emulators or simulators.
    • Supports all the major platforms: iOS, Android, Windows, Firefox OS.

    Of course, Appium is not perfect. There are also some disadvantages:

    • Supports Android versions starting from 17 and later. Earlier versions are not supported.
    • There is no direct support of Android alerts handling.
    • It has more than 50 open bugs related to iOS.

    For Appium installing we need to carry out the following steps:

    • Install Java JDK and write the paths to it in the JAVA_HOME environment variable;
    • Then install Apache Maven. Create environment variables for Maven;
    • Install Node.js;
    • Install Appium using the npm install appium command;
    • Install appium-doctor to check all the dependencies for Appium using the command npm install -g appium-doctor;
    • Run the appium-doctor with the –ios or –android parameter to make sure all the dependencies has been installed correctly.
      While testing a native application to run Appium in the console you need to run the command:

    appium –address “127.0.0.1” –command-timeout “0” –session-override –debug-log-spacing –automation-name “Appium” –platform-name “Android” –platform-version “6.0” –app ‘way to apk file of tested application’ –device-name “device name”

    Installation and configuration of Android SDK

    Android SDK is a universal mobile application development tool for Android operating system. A distinctive feature of the Android SDK from common editors for code writing is the presence of extensive functionality that allows to run testing and debugging of source codes, evaluate work of the application in compatibility mode with different versions of Android OS and watch the result in real time.

    Android SDK supports a large number of mobile devices, among which are: mobile phones, tablet computers, smart glasses (including Google Glass), modern cars with on-board computers based on Android OS, televisions with extended functionality, special types of watches and many other mobile gadgets and overall technical devices.

    For work we need to install Android SDK (SDK tools package) with support of API Level 17 or later.

    At first, it is necessary to create the environment variable ANDROID_HOME

    • For Windows:

    ANDROID_HOME=C:\ installation location \android-sdk PATH=%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

    After that it is needed to download necessary packages with the help of Android SDK Manager:

    • Tools > Android SDK Tools
    • Tools > Android SDK Platform-tools
    • Tools > Android SDK Build-tools
    • SDK Platform (most recent version)> SDK Platform
    • SDK Platform (most recent version) > ARM EABI v7a System Image
    • Extras -> Android Support Repository
    • Extras > Android Support Library
    • Extras -> Google Repository
    • Extras -> Google USB Driver (Required on Windows systems only)
    • Extras > Intel x86 Emulator Accelerator (HAXM installer)

    Installation and configuration of Android device

    In order for the Android device emulator to work at a speed close to the work speed of a real device, you need to install Intel Hardware Accelerated Execution Manager. This will help reduce the time to run and debug the application.

    Intel Hardware Accelerated Execution Manager (Intel HAXM) is a solution that works in pair with an Android emulator for x86 devices and uses hardware virtualization capabilities (Intel VT).

    Using Intel HAXM you can run several copies of Android emulator on one computer without worrying about productivity, system load or about interface “brakes”. Such an approach can be rather useful in an iterative process of creating and testing of applications, it can give a huge increase in developers productivity.

    Android emulator images that are intended for architecture, which is different from x86, can run slowly and respond to user’s commands with delay. In addition, unlike some third-party produced Android emulators, with the help of Intel HAXM you get the opportunity to work with the latest versions of API and Android platforms right away after their release.

    Installation of Intel Hardware Accelerated Execution Manager

    Visit the website https://software.intel.com/en-us/android and download installation package for your platform. Unpack the package to the extras directory located in the directory, where the Android SDK was installed, go to that directory and launch the Intel HAXM installation and follow the tips of the installation wizard.

    During the installation you will be offered to determine the amount of allocated RAM. You can leave the value by default. If during the work you want to change this value – run the installation once again.

    During the installation process this error may occur

    In this case check the settings in BIOS, perhaps virtualization by default is disabled.

    In order to check that everything is installed correctly and works you need to run the following command line:

    • sc query intelhaxm

    After executing this command, you will see the current status of the service.

    Installation of Android x86 emulator

    Now it is needed to install the emulator which will work with Intel HAXM.

    It is installed with the help of Android SDK Manager. Run, tick images we are interested in and install.

    Run AVD Manager

    Press Create button and fill the parameters of the new AVD.

    • In the properties window set an arbitrary name, for example “Intel_Android”
    • Choose the version, in my case the version is “Android 6.0 – API Level 23”
    • Set other parameters (size and availability of the SD card, resolution, etc.)
    • Next tick the checkbox “Use Host GPU”

    Press OK.

    We run and check whether everything is configured correctly. Next, go to the settings and find the name of the device. If everything was done correctly, in the “Model number” field, we will see the line “Android SDK Build for x86”. 

    Real device configuration

    With the help of Android SDK manager (or manually, in the directory \extras\google\usb_driver\) it is needed to install and configure ADB, Android Debug Bridge.

    ADB, Android Debug Bridge is a command line utility with which you can copy files to and from the device, install and remove applications, perform backup and restore, and much more using commands.

    Then, on a real device, you need to switch on USB debugging. To learn how to do this, follow the link

    https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm

    After switching on USB debugging, unlock your smartphone or tablet. Do not use the USB 3.0 port, only USB 2.0 while connecting to a computer.

    When the device is connected to the computer for the first time, there will be a query to trust the computer: tick the box and click OK. USB debugging is turned on.

    In order to check whether ADB sees your phone, use the command

    • adb devices

    If the computer does not recognize your device, click on the link:

    https://www.babaei.net/blog/2016/01/26/android-install-adb-drivers-for-any-device-without-oem-drivers/, this should help.

    After installing and configuring of the software, required for testing Android, you can start writing tests themselves and running them on a mobile device or emulator.

    Useful links