手机自动化测试: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是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣 ...
随机推荐
- strpos、 strstr、 substr三个函数的对比讲解
mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) 返回 needle 在 haystack 中首次出现的数字 ...
- C# 运行时通过鼠标拖动改变控件的大小
来源:http://blog.csdn.net/yanleigis/article/details/1819447 using System; using System.Collections.Gen ...
- Python之路--你不知道的platform
某次在查看测试机(Ubuntu)发行版本时,发现得到的结果并不准确:本应得到Ubuntu,结果显示的却是Debian,大致代码如下 ... distribution_name = ['centos', ...
- 学习接水系统(java+thread线程)
(一)项目框架分析 对于学生并发接水项目,根据面向对象的思想,需要创建两个对象,即学生和水龙头. 接下来主要讲解不排队接水和排队接水两张情况. 项目的目录文件如下: (二)不排队接水 假设有四个学生小 ...
- jwplayer 禁止视频的快进,但是可以后退(已实现)
一直在研究.net 的视频播放,最近做起了jwplayer,然后项目要求是视频不能快进,但是可以重复观看已经看过的视频资源. 很简单 在标签<script> 中定义两个变量 var max ...
- sql server数据库备份压缩拷贝实例
--数据库备份压缩拷贝实例:前提要安装RAR压缩软件--声明变量declare @day varchar(10),@dbname varchar(20),@filename varchar(100), ...
- Linux的capability深入分析
Linux的capability深入分析详见:http://blog.csdn.net/u014338577/article/details/48791953 lxd中对容器能力的限制: 普通用户不能 ...
- 1054: [HAOI2008]移动玩具
1054: [HAOI2008]移动玩具 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1272 Solved: 690[Submit][Statu ...
- 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题
3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: ...
- 1620: [Usaco2008 Nov]Time Management 时间管理
1620: [Usaco2008 Nov]Time Management 时间管理 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 506 Solved: ...