Skip to content

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

Laolu Benson edited this page Nov 20, 2019 · 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;

...

AppiumOptions capabilities = new AppiumOptions();

capabilities.AddAdditionalCapability("deviceName", "Android Emulator");
capabilities.AddAdditionalCapability("platformName", "Android");
capabilities.AddAdditionalCapability("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;
...

AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "8.0");
capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");
capabilities.AddAdditionalCapability(MobileCapabilityType.App, <path to your app>);
AppiumDriver<IOSElement> driver = 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