AndroidDriver和IOSDriver需要具有DesiredCapabilities作为输入。 现在,不推荐使用该驱动程序吗?
我的代码示例:
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("deviceName", ConfigReader("DeviceID"));
cap.SetCapability("udid", ConfigReader("DeviceID"));
cap.SetCapability("platformName", "Android");
cap.SetCapability("systemPort", "SystemPort");
cap.SetCapability("language", ConfigReader("Language"));
cap.SetCapability("locale", ConfigReader("Language"));
IWebDriver driver = new AndroidDriver<AppiumWebElement>(new Uri(uri), cap);
考虑到DesiredCapabilities弃用,我是否可以找到替代此方法的真实示例?
还有一个类似的主题,仍然没有正确的答案DesiredCapabilities for Selenium native android application obsolete
答案 0 :(得分:0)
我们可以使用AddAdditionalCapability http://appium.io/docs/en/commands/session/create/
创建一个会话AppiumOptions capabilities = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1.1");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Device");
appiumOptions.AddAdditionalCapability("appPackage", "com.instagram.android");
appiumOptions.AddAdditionalCapability("appActivity", "com.instagram.android.activity.MainTabActivity");
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);