简体   繁体   中英

AndroidDriver constructor rises NullReferenceException

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?

该错误已在最新的Appium.Webdriver版本中解决。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM