gpt4 book ai didi

c# - 如何在没有 DesiredCapabilities(已弃用)的情况下使用 AndroidDriver 或 IOSDriver?

转载 作者:行者123 更新时间:2023-12-05 07:31:22 25 4
gpt4 key购买 nike

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 弃用,我能否获得替代方案的真实示例?

android 也有一个类似的主题仍然没有正确的答案DesiredCapabilities for Selenium native android application obsolete

最佳答案

我们可以使用 AddAdditionalCapability 创建 session 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);

关于c# - 如何在没有 DesiredCapabilities(已弃用)的情况下使用 AndroidDriver 或 IOSDriver?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51853841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com