您现在的位置是:首页 > 文章详情

Appium Android Driver 简单修改

日期:2017-06-18点击:336

【注】文中提起的 Appium 版本為 v1.6.5

对 Appium Driver 进行简单的修改,并更新方式如下:

  1. 修改 appium-android-driver 中文件,比如去掉对 app 依赖的错误日志
$ vim appium-android-driver/lib/driver.js 

具体修改如下:

 diff --git a/lib/driver.js b/lib/driver.js index 2e60375..fbe2035 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -444,7 +444,8 @@ class AndroidDriver extends BaseDriver { if ((!caps.browserName || !helpers.isChromeBrowser(caps.browserName)) && !caps.app && !caps.appPackage) { let msg = 'The desired capabilities must include either an app, appPackage or browserName'; - log.errorAndThrow(msg); + //log.errorAndThrow(msg); + log.warn(msg); } // warn if the capabilities have both `app` and `browser, although this // is common with selenium grid 
  1. 编译并安装修改:
 $ npm install 
  1. 执行测试即可:
void setupAndroid(String url, String deviceName, String udid, String version, File app, String browserName, String packageName, String activity) throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, version); if (StringUtils.isEmpty(deviceName)) { deviceName = "Android"; } capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName); // support Chinese capabilities.setCapability("unicodeKeyboard", "True"); capabilities.setCapability("resetKeyboard", "True"); // support noSign apk capabilities.setCapability("noSign", "True"); if (!StringUtils.isEmpty(udid)) { capabilities.setCapability(MobileCapabilityType.UDID, udid); } if (!StringUtils.isEmpty(packageName) && !StringUtils.isEmpty(activity)) { capabilities.setCapability("appPackage", packageName); capabilities.setCapability("appActivity", activity); } else if (app != null) { capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); } else if (!StringUtils.isEmpty(browserName)) { capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, browserName); } else { capabilities.setCapability("autoLaunch", false); } mDriver = new AndroidDriver<MobileElement>(new URL(url), capabilities); } setupAndroid("http://127.0.0.1:4492/wd/hub", null, null, null, null, nul, null); 
原文链接:https://yq.aliyun.com/articles/670056
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章