gpt4 book ai didi

c# - Selenium native android 应用程序的 DesiredCapabilities 已过时

转载 作者:太空狗 更新时间:2023-10-29 14:38:43 34 4
gpt4 key购买 nike

我正在尝试设置一个 selenium 框架来测试 android 模拟器上的应用程序。但是,我不断收到 DesiredCapabilities 已过时的警告。除了与浏览器的关系之外,我找不到任何关于此的信息。但在我的框架中,我正在尝试测试 native 应用程序。

代码:

    [TestMethod]
public void Test_Open_Mobile_App()
{
DesiredCapabilities cap = new DesiredCapabilities();

//set the emulator
cap.SetCapability("platformVersion", "8.1");
cap.SetCapability("platformName", "Android");
cap.SetCapability("deviceName", "Device 01 Oreo_1440x2560");
cap.SetCapability("udid", "emulator-5554");
cap.SetCapability("deviceType", "phone");
cap.SetCapability("device", "Android");
cap.SetCapability("app", "C:/Users/User/Desktop/Mobile Tests/App APK/com.hyperspheric.go4schools.apk");
cap.SetCapability("appPackage", "appPackage");
cap.SetCapability("appActivity", "appActivity");


_driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);
}

最佳答案

由于 DesiredCapabilites 在最新的 selenium 驱动程序中已过时,我们可以为任何浏览器使用特定的浏览器选项,对于 android native 应用程序,我们可以使用 AppiumOptions。下面的代码应该适用于 Android 原生应用。

        AppiumOptions cap = new AppiumOptions();

//set the emulator
cap.AddAdditionalCapability("platformVersion", "8.1");
cap.AddAdditionalCapability("platformName", "Android");
cap.AddAdditionalCapability("deviceName", "Device 01 Oreo_1440x2560");
cap.AddAdditionalCapability("udid", "emulator-5554");
cap.AddAdditionalCapability("deviceType", "phone");
cap.AddAdditionalCapability("device", "Android");
cap.AddAdditionalCapability("app", "C:/Users/User/Desktop/Mobile Tests/App APK/com.hyperspheric.go4schools.apk");
cap.AddAdditionalCapability("appPackage", "appPackage");
cap.AddAdditionalCapability("appActivity", "appActivity");

关于c# - Selenium native android 应用程序的 DesiredCapabilities 已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51728126/

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