Sunday, March 27, 2016

Test Automation on Android using Appium, C# and MSTest

This is a two part series of test automation on android using Appium, C# and MSTest.
for part 2 click here.

Prerequisites for this tutorial:

  1. Visual Studio Ultimate (2010 or above) (Because MSTest is present in that)
  2. Android SDK For Windows (Download Link) (Website link)
  3. Appium For Windows (Download Link) (Website Link)
  4. A Real Android Device running Android 4.2 or Above (I am using an Android Phone running Android 4.3)
  5. A USB Cable to attach your Android Phone to Your PC.
  6. ADB Interface Drivers for your Phone (Link on how to get that ) (very important Step)

Some Configurations for Android SDK and Appium:

  • When you have installed Android SDK, go to My Computer, right click , click Properties, click Advanced System Settings, click Environment Variables.
  • Create a new User Variable with the name "ANDROID_HOME". Give path to your sdk folder in the value. The default path is  C:Program Files (x86)Androidandroid-sdk

  • Edit the PATH variable in "System Variable" Section. Append the path to your tools folder and platform-tools folder. Separated with ";"
The paths are
C:Program Files (x86)Androidandroid-sdktools
C:Program Files (x86)Androidandroid-sdkplatform-tools
See the image below.

  •  Connect your Android Phone with USB Cable. To make sure your android phone is connected with your PC, we have to do following.
Go to C:Program Files (x86)Androidandroid-sdktools. Click on "uiautomatorviewer.bat". A window will open. See Image.

 You can use this window to inspect the elements of your app in android. Open the calculator app in your android device and click on "Device ScreenShot" button on this screen. If you receive this error message "No Android devices were found by adb"

That means adb interface drivers are not installed on your system. You have to read again point number 6 in the Prerequisites section. If android device is successfully connected, you should see a snapshot along with Object Map in this window like this.

  • Unzip in a folder. Open Appium.exe, you should see a window like this.

Click on the android Icon on the top left of this window. You will see a window in which you can configure the platform and version of your android on which you want to test. I have filled the following configurations there.

Now click on the Play button on the top right corner of the window. Appium server will start with the configurations you have provided.

  • Developer options should be enabled on your android phone, with these two options.
Usb Debugging should be enabled.
StayAwake should be enabled.
If you reach till here, Congratulations, You have successfully configured all the required prerequisites .
In the second part, I will show how to code and run this script on your real android device.


  1. Thanks for this - it has been extremely helpful! Just a note, the link to second part (last sentence above) does not link properly. Overall, this has been excellent though!

  2. Thanks a lot man, this was really helpful.

  3. iZombie Season 3 will portray Liv gulping down the brain of a dominatrix. Therefore, we can expect the upcoming installment to be more engaging than the previous ones. iZombie Season 3 Cast

    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.

  4. hello!,I like your writing so a lot! percentage we keep in touch more approximately your article on AOL? I need a specialist in this space to unravel my problem. May be that's you! Looking forward to see you. gmail email login

  5. There are many android phones available throughout the world. Many of them have not appeared in North America, however. oukitelcentral

  6. Be that as it may, the receptiveness and its enormous piece of the overall industry made Android helpless against visit security assaults.more information

  7. An open source tool that is required for mobile web, automating Native and hybrid application on Android and IOS platform is known as Appium which was in 2012. Appium is considered to be a cross platform that will low you to write tests which is against multiple platforms like Android and IOS. They do this using the same API. Know More info Click Here:: Appium IOS.

  8. For instance, a binary options investor may look at a company stock that is currently valued at $20 per share and bet $100 that the price will rise to $20.50 or higher by the end of the day.Binary Options Beginners guide