HomeAppium

Mobile app testing automation – Appium and Android Studio

Mobile app testing automation – Appium and Android Studio
Like Tweet Pin it Share Share Email

This is one of the exciting areas for all testers and had picked up a lot of value in the recent past. A huge number of opportunities are available now in the market for test automation of mobile app testing, especially using Appium, Android Studio & Selenium WebDriver.

The very first time when I explored this area, I struggled for around three days to get this working facing errors one after the other. I am now writing this article for my readers, so that they can save their time from figuring out how to get started with simple automation of mobile app testing.

Before I dive in to detailed steps, I would like to share with you the environment I worked on for test automation of mobile app testing.

S.No Platform / Tool / Software Version / Measure
 1  Operating System  Windows 7
 2  Appium  1.4.16.1
 3  Android Studio  2.2.3
 4  RAM  8 GB
 5  JDK – Java  1.8.0.112
 6  Selenium – WebDriver – Java Libraries  selenium-java-3.0.1
 7  Selenium – Standalone Server selenium-server-standalone-3.2.0.jar
 8 Mobile Emulator – Google Nexus 5 – Atom Android Version 7.0 / Android N

API Level 24

 

Step by step instructions to automate mobile app testing using appium, android studio, selenium webdriver.

 

Step 1: Setting up Mobile app testing automation environment

 

Download the following list of software:

 

Software installation

  • Detailed steps to install java
  • Installation of Android Studio – Steps are quite self explanatory.
  • Installation of  Appium Server – Steps are quite self explanatory.

Just make sure that you have administrative rights to install the software.

Setting required environment variables.

  • Right click on “Computer”
  • Select “Properties” Menu
  • Click on “Advanced System Settings” you will be presented with “System Properties” window
  • Click on “Environment Variables” Button 
  • Under System Variables section
    • Add a new variable as per the first option mentioned in the below table.
    • Update existing Path variable as per the second option mentioned in the below table
S.No System Variable Value for System Variable
1 ANDROID_HOME C:\Users\{username}\AppData\Local\Android\sdk\
2 PATH {ExistingPATH};%ANDROID_HOME%\tools\;%ANDROID_HOME%\platform-tools\;

Important Note: During further steps, if you face any issue that is stopping you from proceeding, I would recommend you to refer to the last section of this article which is the troubleshooting section. I had drafted the issues and solutions for the issues I faced in the entire process or automating mobile app testing in a mobile emulator. It might help you in saving time.

Step 2: Creating project in Android Studio

In this step you will be covering following activities

S.No Activity Title Activity steps
1 Create project Detailed steps to create android project in Android Studio.
2 Add Libraries Detailed steps to add selenium libraries to the above created project.
3 Create test script Detailed steps to create a test script with in the project created above.

 

While you are creating the selenium test automation script to automate mobile app testing , following two concepts will be highly handy for you.

S.No How to’s Detailed steps link
1  Identify objects How to find android mobile app object’s attributes and their values? i.e. to form the xpath, and to use in selenium webdriver script
2 Identify Mobile Application package and MainActivity How to identify the Mobile application’s package name and Launcher Activity name, the details which are required for writing the selenium WebDriver script.

 

Step 3: Execute your first Mobile App Testing automation script

In this step you will be covering following activities

S.No Activity Title Activity steps
1 Create virtual device Detailed steps to create virtual device in android studio.
2 Start Appium Detailed steps to open and start appium server along with settings.
3 Launch emulator & execute test script Detailed steps to launch mobile emulator and execute the test script created in earlier steps.

Reference: Troubleshooting issues when working on mobile app testing automation

When you are working with Appium, Android Studio, Selenium WebDriver to automate the mobile application testing you might encounter issues and keeps you at hold, you will not be able to proceed any step further.

Issues might appear in different steps of the entire process, like:

S.No Issue at step Issue Solution
1 Creation of project and configuring the selenium libraries  Unable to import junit or other libraries and code errors / Gradle unable to pull required dependencies
2 Execution of test automation script INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling , similarly for io.appium.unlock app.
ps uiautomator error
Device is not online error:

Some times when you see this error in appium server, you have to first stop mobile emulator & appium server.

Later launch and start appium server and start the mobile emulator, doing these steps will help in resolving the error. It is mandatory to follow the order of steps.

 

Request you to kindly share any of your queries in form of comments, we would try our best to provide a solution for you.

Comments (6)

  • I am done with all required setup/configuration for mobile testing. But I am unable to build successfully. Its showing “BUILD FAILED” message in Messages Gradle Build tab. Please could you give any solution for it.

    Following is the error details:

    Error:Gradle: A problem occurred configuring root project ‘MobileTesting’.
    > Could not resolve all dependencies for configuration ‘:classpath’.
    > Could not resolve com.android.tools.build:gradle:2.3.0.
    Required by:
    project :
    > Could not resolve com.android.tools.build:gradle:2.3.0.
    > Could not get resource ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’.
    > Could not GET ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’.
    > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/159.122.18.156] failed: Connection refused: connect

    Thanks in advance.

    Reply
  • Thanks Srinivas. I made changes in gradle.properties file. Now, it is working fine.

    Reply

Leave a Reply

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