C# Appium Desired Capabilities settings
I will cover Appium setup in another blog . Once the Appium setup is done ,next step is to set DesiredCapabilities for the Appium webdriver.
Below is the sample code in C#
Below is the sample code in C#
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(MobileCapabilityType.PlatformName, "iOS");
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "9.3");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone 6");
capabilities.SetCapability(MobileCapabilityType.NewCommandTimeout,60*3);
capabilities.SetCapability(IOSMobileCapabilityType.LaunchTimeout, 60*10);
capabilities.SetCapability(MobileCapabilityType.PlatformName, "iOS");
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "9.3");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone 6");
capabilities.SetCapability(MobileCapabilityType.NewCommandTimeout,60*3);
capabilities.SetCapability(IOSMobileCapabilityType.LaunchTimeout, 60*10);
//replace with your app path
capabilities.SetCapability(MobileCapabilityType.App, "IOS app path(*.app)");
AppiumDriver = new IOSDriver(new Uri("http://172.*.*.*:4723/wd/hub"), capabilities);
AppiumDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(1));
capabilities.SetCapability(MobileCapabilityType.App, "IOS app path(*.app)");
AppiumDriver = new IOSDriver
AppiumDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(1));
One important point here is that you need to give ip address of Appium server where it is running . In my case C# code is triggered from windows parallels and Appium server is running on the MAC side so both on one box so i need to specify my mac ip address in the highlighted portion of the code.
On the side note, it is always good idea to declare ImplicitWait in the driver initialization area rather than different places in the code because implicit wait is set for lifecycle of the webdriver (like global setting).
Nice blog... I found this blog very helpful and want to share best code analysis tools c#. This tool is very useful for all C# developers.
ReplyDelete