手机自动化测试: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");
}
}
}
转载于:https://www.cnblogs.com/poptest/p/4950606.html
手机自动化测试:appium源码分析之bootstrap八相关推荐
- 手机自动化测试:appium源码分析之bootstrap十二
手机自动化测试:appium源码分析之bootstrap十二 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请 ...
- 手机自动化测试:appium源码分析之bootstrap七
手机自动化测试:appium源码分析之bootstrap七 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.poptest测试开发 ...
- 手机自动化测试:appium源码分析之bootstrap六 (下)
代码的步骤和swipe类似,而且最终调用的也是UiDevice.swipe方法,那么我们来看看到底区别在什么地方.首先它也分控件和坐标,分别分析: 控件 首先将控件的中心点作为起始坐标,然后根据提供的 ...
- 手机自动化测试:Appium源码分析之跟踪代码分析四 1
手机自动化测试:Appium源码分析之跟踪代码分析四 控制器模块 // Appium webserver controller methods // https://github.com/hugs/a ...
- CTS(11)---android自动化测试CTS源码分析之一
android自动化测试CTS源码分析之一 1, 概述 CTS(Compatibility Test Suite)全名兼容性测试,主要目的就是让Android设备开发商能够开发出兼容性更好的andro ...
- app自动化测试之Appium 源码分析
Appium 是由 Node.js 来实现的 HTTP 服务,它并不是一套全新的框架,而是将现有的优秀的框架进行了集成,在 Selenium WebDriver 协议(JsonWireProtocol ...
- spark 源码分析之十八 -- Spark存储体系剖析
本篇文章主要剖析BlockManager相关的类以及总结Spark底层存储体系. 总述 先看 BlockManager相关类之间的关系如下: 我们从NettyRpcEnv 开始,做一下简单说明. Ne ...
- 【转】ABP源码分析二十八:ABP.MemoryDB
这个模块简单,且无实际作用(该模块用于支持ABP框架单元测试的).一般实际项目中都有用数据库做持久化,用了数据库就无法用这个MemoryDB 模块了.原因在于ABP限制了UnitOfWork的类型只能 ...
- ABP源码分析二十八:ABP.MemoryDB
这个模块简单,且无实际作用.一般实际项目中都有用数据库做持久化,用了数据库就无法用这个MemoryDB 模块了.原因在于ABP限制了UnitOfWork的类型只能有一个(前文以作介绍),一般用了数据库 ...
最新文章
- ICCV2021|首届城市规模点云语义理解挑战赛启动了
- oracle:ORA-01940无法删除当前已连接用户的解决方案
- HDU 2147 kiki's game
- Google正式收购百度
- Linux中的mysql.redis
- java的几_Java的几种时间
- 【今日CV 计算机视觉论文速览】Fri, 22 Feb 2019
- 《追风筝的人》卡勒德·胡赛尼著小说成长的故事
- 安卓linux输入代码在哪里,输入 | Android 开源项目 | Android Open Source Project
- SQL注入漏洞 攻击
- 《微机原理与应用》题库
- 环世界服务器显示不出来,环世界控制台代码 | 手游网游页游攻略大全
- 【学习笔记】Creo如何创建钣金件(利用骨架)
- sap的工作日历_ABAP-有关日期的SAP函数使用(日历)
- iOS关于应用出现未验证应用的解决方法
- LabWindows操作Access
- 基于PHP+Html+MySQL的网上手机商城系统
- 用python画一个机器猫歌词_用Python语言模型和LSTM做一个Drake饶舌歌词生成器
- 未转变者服务器bug,未转变者BUG问题解决 | 手游网游页游攻略大全
- html5图片格式有什么,jpeg是什么?
热门文章
- Linux下用户管理
- 我脸都问绿了!二面竟然被问到 MySQL 时间类型 datetime、bigint 及 timestamp 的查询效率。。。
- 如何优雅的处理业务逻辑中的定时和延时问题?
- 反思~我们是否应当克制对新技术的追求?
- 磁盘满了,为啥du却显示还有很大空间?
- Spring框架中的设计模式(三)
- 职责链模式 php,php Chain of Responsibility 职责链模式
- mysql40题_mysql40题
- 如何发布php网站_php网站如何发布【货币问答】- 联合货币
- springboot 整合mybatis_SpringBoot整合MyBatis框架快速入门