Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用AppiumDriver<;MobileElement>;司机_Android_Ios_Appium - Fatal编程技术网

Android 使用AppiumDriver<;MobileElement>;司机

Android 使用AppiumDriver<;MobileElement>;司机,android,ios,appium,Android,Ios,Appium,我只是想弄清楚我需要在Android和iOS设备上测试移动应用程序的驱动程序类型。我的主要目标是为这两个平台保持相同的代码基础——尽管,将它们分开会更容易实现;但很难维持 话虽如此,我很好奇下面的代码片段是否能在这种情况下工作 AppiumDriver<MobileElement> driver = null; if ("iOS".equals(os)) { driver = new IOSDriver<MobileElement>(new URL(urlStr

我只是想弄清楚我需要在Android和iOS设备上测试移动应用程序的驱动程序类型。我的主要目标是为这两个平台保持相同的代码基础——尽管,将它们分开会更容易实现;但很难维持

话虽如此,我很好奇下面的代码片段是否能在这种情况下工作

AppiumDriver<MobileElement> driver = null;

if ("iOS".equals(os)) {
    driver = new IOSDriver<MobileElement>(new URL(urlString), capabilities);
} else {
    driver = new AndroidDriver<MobileElement>(new URL(urlString), capabilities);
}
AppiumDriver驱动程序=null;
如果(“iOS”。等于(os)){
驱动程序=新IOSDriver(新URL(urlString),功能);
}否则{
驱动程序=新的AndroidDriver(新的URL(urlString),功能);
}
是的,您提到的代码片段适用于您的情况

AppiumDriver<MobileElement> driver = null;

if ("iOS".equals(os)) {
    driver = new IOSDriver<MobileElement>(new URL(urlString), capabilities);
} else {
    driver = new AndroidDriver<MobileElement>(new URL(urlString), capabilities);
}
AppiumDriver驱动程序=null;
如果(“iOS”。等于(os)){
驱动程序=新IOSDriver(新URL(urlString),功能);
}否则{
驱动程序=新的AndroidDriver(新的URL(urlString),功能);
}
创建的驱动程序实例将是MobileElement类型。

私有AppiumDriver\u驱动程序;
公共只读字符串platform=“iOS”;
交换机(平台)
{
案例MobilePlatform.Android:
_驱动程序=新的AndroidDriver(新的
Uri(“http://localhost:4723/wd/hub例如,驱动程序,
时间跨度从秒(300));
打破
案例MobilePlatform.IOS:
_驱动程序=新的IOSDriver(新的
Uri(“http://127.0.0.1:4723/wd/hub例如,驱动程序,
时间跨度从秒(300));
打破
}

请添加一些说明,以澄清您的解决方案或任何其他感兴趣的用户。
private AppiumDriver<AppiumWebElement> _driver;
public readonly string platform = "iOS";

switch (platform)
        {
            case MobilePlatform.Android:
                _driver = new AndroidDriver<AppiumWebElement>(new 
Uri("http://localhost:4723/wd/hub"), driverOptions, 
TimeSpan.FromSeconds(300));
                break;
            case MobilePlatform.IOS:
                _driver = new IOSDriver<AppiumWebElement>(new 
Uri("http://127.0.0.1:4723/wd/hub"), driverOptions, 
TimeSpan.FromSeconds(300));
                break;
        }