I want to use Appium to make automated testing for my Android app. I downloaded the Appium for Windows and could run my app on device from within appium.exe. Now I want to write test cases in C# which make use of selendroid
integrated in Appium. I googled a lot but couldn't find any example demonstrating the same. I found one project on github but it's giving a lot of compiler errors. Could anybody guide me about how to write test cases using Appium in C#? If you have any resources, please provide me the same. Thanks.
Asked
Active
Viewed 6,597 times
1

Tejas Sutar
- 747
- 2
- 11
- 33
2 Answers
3
You can go with installing Visual Studio 2012 or visual express for web. Use NUnit framework to write the test cases and execute them as a class library project in that.

Vignesh
- 165
- 4
- 15
-
it will be appreciated if you could provide resources/links to achieve what you have just mentioned. – Roy Lee Sep 04 '14 at 08:42
-
There are no such links to help on this , i downloaded visual studio , created an class library project then used the NUnit structure to set up the capabilities and started writing the test cases. https://www.nuget.org/packages/Appium.WebDriver/ <-- this link will explain how to add the Appium Webdriver references to your class library project. https://www.nuget.org/packages/Newtonsoft.Json/ and https://www.nuget.org/packages/Selenium.WebDriver/ packages are needed to initialize the webdriver to connect to the Appium server. – Vignesh Sep 04 '14 at 09:52
-
I guess this link will be very much useful in adding the dll files and also configure the NUnit framework to write your test cases and build your project accordingly. http://blog.wedoqa.com/2012/02/how-to-setup-selenium-webdriver-with-visual-studio-and-nunit/ – Vignesh Sep 04 '14 at 10:08
-
https://github.com/appium/appium-dotnet-driver . This link will be helpful for you with a basic start. – Vignesh Sep 11 '14 at 03:57
0
1) Create a class library project and create a new class e.g "Class1". Add the packages as provided in the links above. Try the below code
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using NUnit.Framework;
using OpenQA.Selenium.Interactions;
using System.Threading;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Appium.Interfaces;
using System.Drawing;
namespace ClassLibrary2
{
[TestFixture]
public class Class1
{
public AppiumDriver driver;
public DesiredCapabilities capabilities;
public Class1()
{
Console.WriteLine("Connecting to Appium server");
capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "Android");
capabilities.SetCapability(CapabilityType.Platform, "Windows");
capabilities.SetCapability(CapabilityType.Version ,"4.1.2");
capabilities.SetCapability("Device", "Android");
//Application path and configurations
driver = new AppiumDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
}
[Test]
public void login()
{
driver.FindElement(By.Name("Country")).Click();
//Your further code as per the application.
}
Then Build a solution for your project and run it in NUnit.

Vignesh
- 165
- 4
- 15