手机自动化测试:appium源码分析之bootstrap八
手机自动化测试:appium源码分析之bootstrap八
poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。如果对课程感兴趣,请大家咨询qq:908821478,今天是移动端测试开发课程开课,学员们学习热情很高。我们发现测试培训一个有趣的特点,周末学习提高的女孩子多,就业培训参加的男孩子比例高,
概念:pinchIn和pinchOut
a.2个手指同时按住A和B,同时将A滑向A1,B滑向B1,称为pinchIn
b.2个手指同时按住A1和B1,同时将A1滑向A,B1滑向B,成为pinchOut.
那么Pinch类就是接受这一指令的,传入的参数有方向direction,percent代表滑到对角线百分之几停止,steps代表滑到时间,一个step代表5毫秒。根据direction来判断是调用UiObject.pinchIn和UiObject.pinchOut.
Pinch代码:
package io.appium.android.bootstrap.handler;
import com.android.uiautomator.core.UiObjectNotFoundException;
import io.appium.android.bootstrap.*;
import org.json.JSONException;
import java.util.Hashtable;
/**
* This handler is used to pinch in/out elements in the Android UI.
*
* Based on the element Id, pinch in/out that element.
*
*/
public class Pinch extends CommandHandler {
/*
* @param command The {@link AndroidCommand} used for this handler.
*
* @return {@link AndroidCommandResult}
*
* @throws JSONException
*
* @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android.
* bootstrap.AndroidCommand)
*/
@Override
public AndroidCommandResult execute(final AndroidCommand command)
throws JSONException {
final Hashtable<String, Object> params = command.params();
AndroidElement el;
final String direction = params.get("direction").toString();
final Integer percent = (Integer) params.get("percent");
final Integer steps = (Integer) params.get("steps");
try {
el = command.getElement();
if (el == null) {
return getErrorResult("Could not find an element with elementId: "
+ params.get("elementId"));
}
} catch (final Exception e) { // JSONException, NullPointerException, etc.
return getErrorResult("Unknown error:" + e.getMessage());
}
Logger.debug("Pinching " + direction + " " + percent.toString() + "%"
+ " with steps: " + steps.toString());
boolean res;
if (direction.equals("in")) {
try {
res = el.pinchIn(percent, steps);
} catch (final UiObjectNotFoundException e) {
return getErrorResult("Selector could not be matched to any UI element displayed");
}
} else {
try {
res = el.pinchOut(percent, steps);
} catch (final UiObjectNotFoundException e) {
return getErrorResult("Selector could not be matched to any UI element displayed");
}
}
if (res) {
return getSuccessResult(res);
} else {
return getErrorResult("Pinch did not complete successfully");
}
}
}
手机自动化测试:appium源码分析之bootstrap八的更多相关文章
- 手机自动化测试:appium源码分析之bootstrap三
手机自动化测试:appium源码分析之bootstrap三 研究bootstrap源码,我们可以通过代码的结构,可以看出来appium的扩展思路和实现方式,从中可以添加我们自己要的功能,针对app ...
- 手机自动化测试:appium源码分析之bootstrap二
手机自动化测试:appium源码分析之bootstrap二 在bootstrap项目中的io.appium.android.bootstrap.handler包中的类都是对应的指令类, priva ...
- 手机自动化测试:appium源码分析之bootstrap一
手机自动化测试:appium源码分析之bootstrap一 前言: poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.popte ...
- 手机自动化测试:appium源码分析之bootstrap十七
手机自动化测试:appium源码分析之bootstrap十七 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
- 手机自动化测试:appium源码分析之bootstrap十六
手机自动化测试:appium源码分析之bootstrap十六 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
- 手机自动化测试:appium源码分析之bootstrap十五
手机自动化测试:appium源码分析之bootstrap十五 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
- 手机自动化测试:appium源码分析之bootstrap十四
手机自动化测试:appium源码分析之bootstrap十四 poptest(www.poptest.cn)是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开 ...
- 手机自动化测试:appium源码分析之bootstrap十三
手机自动化测试:appium源码分析之bootstrap十三 poptest(www.poptest.cn)是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开 ...
- 手机自动化测试:appium源码分析之bootstrap十一
手机自动化测试:appium源码分析之bootstrap十一 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
随机推荐
- Bootstrap记录
左侧 导航下拉: <li class="dropdown"> <a href="#" class="dropdown-toggle& ...
- gridcontrol中LayoutView层叠图片效果
1.效果图 2.如上图效果,为比较常见的一种需求,一堆物品图片.有时候需要给不同物品标记,图中左上角就是一张标记性图片.在devexpress里面实现起来也比较容易. 3.部分代码: class Pi ...
- GridControl 设置自带选中复选框及设置该列列头名称
2.设置该列标题,设置事件CustomDrawColumnHeader 效果图:
- BZOJ 1062: [NOI2008]糖果雨(二维树状数组)
首先嘛,这道题是非同一般的恶心= = 然后首先膜拜一下CDQ大神ORZ在考场上A了这道题ORZ 这道题看到的话,我是先想把云朵化成在0s时的位置,但很容易发现这样只能单点查询而不能查询整段 结果只能膜 ...
- Linux实战教学笔记17:精简shell基础
第十七节 精简shell基础 标签(空格分隔): Linux实战教学笔记 1,前言 1.1 为什么学习shell编程 Shell脚本语言是实现Linux/UNIX系统管理及自动化运维所必备的重要工具, ...
- 微信群之Java技术红包问答
缘起 年前公司拿到B+轮融资,相应的在战略上也做了很大的调整,毕竟B轮要做的事情不仅仅是增加用户数,于是乎公司在2017年的开头补充了一部分技术团队,这次人员选择上主要针对一些工作经验在1-2年的技术 ...
- VUE2.0实现购物车和地址选配功能学习第七节
第七节 卡片选中,设置默认 1.卡片选中html:<li v-for="(item,index) in filterAddress" v-bind:class="{ ...
- 百度地图API新手入门
最近,共享单车着实火了一把,市场竞争也是异常的激烈,百花争艳,百家争鸣,群雄逐鹿,最后鹿死谁手,现在还不得而知,不过可以肯定的是细节决定成败,更重要的还在于用户的体验. 用过的同学们都会知道,打开共享 ...
- 1820: [JSOI2010]Express Service 快递服务
1820: [JSOI2010]Express Service 快递服务 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 847 Solved: 325 ...
- aiohttp之添加静态资源路径
所谓静态资源,是指图片.js.css等文件.官方的说明在这里. 以一个小项目来说明,下面是项目的目录结构: . ├── static │ ├── css │ │ ├── base.css │ │ ├─ ...