I use Appium server running on Mac machine and AppiumDriver with c# bindings to execute tests from Windows machine. The issue is that when I create an instance of AndroidDriver its ctor rises a NullReferenceException. When I create an instance of RemoteWebDriver, it works smoothly. This is my code:
var caps = new DesiredCapabilities();
caps.SetCapability(MobileCapabilityType.DeviceName, "Nexus_4");
caps.SetCapability("udid", "<valid-device-id>");
caps.SetCapability(MobileCapabilityType.App, "https://valid/path/to/my.apk");
caps.SetCapability(MobileCapabilityType.PlatformName, MobilePlatform.Android);
using (var drv = new AndroidDriver(ServerUri, caps)) // rises exception
//using (var drv = new RemoteWebDriver(ServerUri, caps)) // works smoothly
{
drv.GetScreenshot().SaveAsFile("Android.png", ImageFormat.Png);
}
Exception:
System.NullReferenceException : Object reference not set to an instance of an object.
Result StackTrace:
at OpenQA.Selenium.Appium.AppiumDriver._AddAppiumCommands()
at OpenQA.Selenium.Appium.AppiumDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Appium.Android.AndroidDriver..ctor(Uri remoteAddress, DesiredCapabilities desiredCapabilities)
Where am I wrong? Why the constructor of AndroidDriver rises this execption and doesn't specify the reason?