Appium: the doorway to automate application testing on Android and iOS

Posted by   June 7th, 2017

Facebooktwitterlinkedinmail

Appium is an open source automation tool which allows the user to automate testing native, hybrid and mobile web applications on Android and iOS devices.

The installation of Appium is quite simple and can be done in the following steps:

  1. Open terminal
  2. Type “ brew install node ” – to install node.js
  3. Type “ npm install -g appium ” – to install appium server
  4. Type “ npm install wd ” – to install appium client
  5. Type “appium” – to start appium server

What I experienced in the project:

Our client had stated that the our project requirement was to automate all the iOS and Android apps with their SDK integrated. I choose Appium for this project.  Our first step involved getting an SDK from client side after which we had to add performance logs and integrate the sdk in apps. For this we wrote a shell script to integrate the SDK into the apps. Our requirement was to automate the app in different devices in Cloud. To do this, I used Genymotion for Android and Amazon Device Farm for iOS. Genymotion is an Android emulator that enables us to develop and test any android application. On the other hand, Amazon Device Farm is an app testing service that enables the user to test the Android, web and iOS application on Cloud.

After building the apps with the SDK integrated, I wrote the code in Java using Appium. I  interacted with the apps using the same. At first, I launched the app and did some operations using Appium and closed the app. I checked the code on a daily basis. After this, I used to ensure that 3 steps were followed:

  1. I wrote a shell script to execute all the apps from a script
  2. The script invoked all the apps after which would do some testing
  3. Then finally, I captured the logs and copied them to a log file

We used our personal devices for testing the app. The network was varying in some situations so we went with genymotion and Amazon device farm. After that we integrated this code to Jenkins and used to run the jobs.  For iOS, we used to execute in Amazon Device Farm through a Command Line Interface(CLI) using a single shell script which runs all the test and captures the logs from Device Farm and copies to a log file.

Steps through which Genymotion can be installed:

Steps to setup the Virtual Box

  • Type command “sudo apt-get install virtualbox” in terminal

Genymotion Download and Installation process:

Install another virtualbox in virtual machine (this is done for the successful running of genymotion to install the first virtualalbox )

1.After having installed Vm virtualBox to run this genymotion application,Download  virtual box according  to your OS from the below link.   (https://www.virtualbox.org/wiki/Downloads)

2.After installing virtualBox, Go to genymotion official page and click on download. (https://www.genymotion.com/account/login/)

Note:In order to download, registration should be done..

3.After downloading the product, we get the file (genymotion-2.8.0-linux_x64.bin).

4.In order to execute genymotion, it is necessary to change the file permission to execute mode using below command.

(chmod +x  genymotion-2.8.0-linux_x64.bin)

Execute .bin file with the following command.

(   ./genymotion-2.8.0-linux_x64.bin  )

Amazon Device Farm Setup:

  1. Requirements:
  • Java
  • Nodejs
  • Appium
  • Eclipse with Maven Plugin
  • Appium Script
  • Enter the following commands to the POM file that you created with the maven project
<groupId>com.acme</groupId>
<artifactId>acme-android-appium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ReferenceAppAppiumTests</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>

<configuration>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>zip-with-dependencies</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
  • Create zip.xml file with below code in src/main folder
<assembly
 xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
 <id>zip</id>
 <formats>
 <format>zip</format>
 </formats>
 <includeBaseDirectory>false</includeBaseDirectory>
 <fileSets>
 <fileSet>
 <directory>${project.build.directory}</directory>
 <outputDirectory>./</outputDirectory>
 <includes>
 <include>*.jar</include>
 </includes>
 </fileSet>
 <fileSet>
 <directory>${project.build.directory}</directory>
 <outputDirectory>./</outputDirectory>
 <includes>
 <include>/dependency-jars/</include>
 </includes>
 </fileSet>
 </fileSets>
</assembly>

  • Run this command in the terminal after going to the project path

mvn clean package -DskipTests=true

Once the command is executed successfully, a zip file named zip-with-dependencies.zip is created in target folder.

  1. How to upload appium script to AWS Device Farm:
  • Login to the Device Farm
  • Click on Create a new project
  • Click on Create a new run

  • Upload the apk or ipa file

  • Upload the zip-with-dependencies.zip file which was created in target folder
  • In Select Devices screen, click on Create a new device pool and select devices which you want to test

  • Click on Next step
  • Specify Device state
  • Click on Review and start run
  • Click on Confirm and start run

  1. Steps to install AWS Device Farm CLI :
  • Open terminal
  • Type “ brew install awscli ”
  • To Verify AWS Device Farm CLI installed or type this command “ aws –version ”
  1. Steps to Configure AWS Device Farm CLI:
  • Open terminal
  • Type “ aws configure ”
  • Then you need to enter following information and press enter
    • AWS Access Key id:
    • AWS Secret Access Key:
    • Default region name:
    • Default output Format:
  1. Steps to configure appium script using AWS Device Farm CLI
  • Open Terminal
  • Type “ aws devicefarm create-project –name project_name ” – for creating a project
  • Type “ aws devicefarm list-device-pools –arn project_arn_value” – for creating device pool
  • Type “ aws devicefarm create-upload –project-arn project_arn_value –name APK_Name –type ANDROID_APP/iOS_APP ” -For creating a method to upload the application ipa file
  • Type “ curl -T URL_Value” – Actual uploading of app ipa. URL_Value will be getting from create upload method method(Previous step)
  • Type “ aws devicefarm create-upload –project-arn project_arn_value –name TestPackage_name –type APPIUM_JAVA_TESTNG_TEST_PACKAGE ” – creating upload method for test package
  • Type “ curl -T URL_Value” – Actual uploading of app ipa. URL_Value will be getting from create upload method method(Previous step)
  • Type aws devicefarm schedule-run –project-arn ${PROJECT_ARN} –app-arn ${APP_ARN} –device-pool-arn ${DEVICEPOOL_ARN} –name ${TESTRUN_NAME} –test ‘{“type”:”APPIUM_JAVA_TESTNG”,”testPackageArn”:”‘${TESTSCRIPT_ARN}'”}’ – To Schedule a run

Leave a Reply

Your email address will not be published. Required fields are marked *