UI Browser Automation using Appium with Visual Studio Android Emulator
Published Mar 13 2019 10:09 AM 17.8K Views
First published on MSDN on Apr 29, 2018

Authored by Ganesh Alalasundaram

Appium is an open source cross platform automation tool for native/hybrid and mobile web based apps.


You can use Appium with various languages like c#, java or Objective C with Selenium driver. Thus it is truly a cross platform automation tool!


The machine which is running the web driver scripts communicates with the Appium server through Http/JSON and in turn Appium sends/receives the command to Devices/Emulators of Android or iOS platforms.

Here we will discuss about the Integration of Appium with Visual Studio using C#.

Pre Requisites:

Setting up the Visual Studio Android Emulator.

  • Search for the visual studio android emulator and open it.

  • Select the latest API level and download the emulator.

  • Run the Emulator.

Setting up the Appium Server

  • Launch Appium.exe from the downloaded folder.

  • Click on Android Icon and change the settings as highlighted.

  • Click Play button.

Getting the Device Name

Goto Android SDK folder in command prompt. And type adb devices -l. This will list all the running devices

Setting up the Visual Studio Project


Create a new Unit Test project in Visual Studio.

Under Reference in Solution Explorer, Click Add Manage Nuget Packages.

Search for ‘Appium’ and install.

Post installation, the references will be updated.

In the .cs file, enter the code below. Initially we instantiate the Appium web driver and set the desired capabilities.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;
namespace Appium
public class AppiumTest

AppiumDriver _driver;

public void TestBrowser()
//Set the capabilities
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("deviceName", "donatello");
cap.SetCapability("platformVersion", "6.0.0");
cap.SetCapability("udid", "");
cap.SetCapability("fullReset", "True");
cap.SetCapability(MobileCapabilityType.App, "Browser");
cap.SetCapability("platformName", "Android");
_driver = new AndroidDriver(new Uri(""), cap);

//Navigate to browser

The Test method above performs actions on the Device default browser. These actions are to:

Navigate to the http://www.bing.com website, then

Type the search text: ‘Microsoft’

Running the Test:

Most common Issues:

1. Unable to connect to remote server – no connection could be made because the target server actively refused it

Resolution : Ensure the Appium server is running. And the IP address is entered correctly in the Appium server settings page. Verify the desired capabilities parameters.

2.  A new connection could not be created. An unknown server side error occurred while processing the command. Unknown error. Device <IP address> is not online.


– Verify if the emulator/device is connected through adb devices -l in command prompt.

– Desired capabilities should be properly entered. Ex: devicename/platformversion/udid/platformname.

– Check for Appium settings. Restart the Appium server.

3. Could not find a connected Android device.


Ensure the android device or emulator is running. (goto command prompt, goto Android SDK\Tools\ and run adb devices -l)

Version history
Last update:
‎Mar 13 2019 10:09 AM
Updated by: