Skip to content

How to start an AppiumDriver when the server is launched remotely or locally

Sergey Tikhomirov edited this page Mar 16, 2016 · 7 revisions

It is not a big deal to start an AppiumDriver using the URL to the Appium server launched remotely/locally.

Android

...
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;

...

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.SetCapability("deviceName", "Android Emulator");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("app", "<Path to your app>");

AppiumDriver<AppiumWebElement> driver = new AndroidDriver<AppiumWebElement>(
                           new Uri("http://127.0.0.1:4723/wd/hub"), 
                               capabilities);		

iOS

...
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.iOS;
...

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "8.0");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");
capabilities.SetCapability(MobileCapabilityType.App, <path to your app>);
AppiumDriver<IOSElement> drive = new IOSDriver<IOSElement>(
                               new Uri("http://127.0.0.1:4723/wd/hub"), 
                                 capabilities);

Capabilities

The full list of capabilities is described here: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md. There are three classes that help to define values of capabilities: OpenQA.Selenium.Appium.Enums.remote.MobileCapabilityType OpenQA.Selenium.Appium.Enums.AndroidMobileCapabilityType OpenQA.Selenium.Appium.Enums.IOSMobileCapabilityType