手机自动化测试:appium源码分析之bootstrap五

poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。poptest测试开发工程师就业培训请大家咨询qq:908821478)移动端自动化测试是未来的测试工程师的技术要求,我们需要打好基础。

Swipe代码:

package io.appium.android.bootstrap.handler;

import com.android.uiautomator.core.UiDevice;

import com.android.uiautomator.core.UiObjectNotFoundException;

import io.appium.android.bootstrap.*;

import io.appium.android.bootstrap.exceptions.InvalidCoordinatesException;

import io.appium.android.bootstrap.utils.Point;

import org.json.JSONException;

import java.util.Hashtable;

/**

* This handler is used to swipe.

*

*/

public class Swipe 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();

final Point start = new Point(params.get("startX"), params.get("startY"));

final Point end = new Point(params.get("endX"), params.get("endY"));

final Integer steps = (Integer) params.get("steps");

final UiDevice device = UiDevice.getInstance();

Point absStartPos = new Point();

Point absEndPos = new Point();

if (command.isElementCommand()) {

try {

final AndroidElement el = command.getElement();

absStartPos = el.getAbsolutePosition(start);

absEndPos = el.getAbsolutePosition(end, false);

} catch (final UiObjectNotFoundException e) {

return getErrorResult(e.getMessage());

} catch (final InvalidCoordinatesException e) {

return getErrorResult(e.getMessage());

} catch (final Exception e) { // handle NullPointerException

return getErrorResult("Unknown error");

}

} else {

try {

absStartPos = getDeviceAbsPos(start);

absEndPos = getDeviceAbsPos(end);

} catch (final InvalidCoordinatesException e) {

return getErrorResult(e.getMessage());

}

}

Logger.debug("Swiping from " + absStartPos.toString() + " to "

+ absEndPos.toString() + " with steps: " + steps.toString());

final boolean rv = device.swipe(absStartPos.x.intValue(),

absStartPos.y.intValue(), absEndPos.x.intValue(),

absEndPos.y.intValue(), steps);

if (!rv) {

return getErrorResult("The swipe did not complete successfully");

}

return getSucce***esult(rv);

}

}

转载于:https://blog.51cto.com/10988776/1726080

手机自动化测试:appium源码分析之bootstrap五 上相关推荐

  1. 手机自动化测试:appium源码分析之bootstrap八

    手机自动化测试:appium源码分析之bootstrap八 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大 ...

  2. 手机自动化测试:appium源码分析之bootstrap十二

    手机自动化测试:appium源码分析之bootstrap十二 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请 ...

  3. 手机自动化测试:appium源码分析之bootstrap七

    手机自动化测试:appium源码分析之bootstrap七 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.poptest测试开发 ...

  4. 手机自动化测试:appium源码分析之bootstrap六 (下)

    代码的步骤和swipe类似,而且最终调用的也是UiDevice.swipe方法,那么我们来看看到底区别在什么地方.首先它也分控件和坐标,分别分析: 控件 首先将控件的中心点作为起始坐标,然后根据提供的 ...

  5. 手机自动化测试:Appium源码分析之跟踪代码分析四 1

    手机自动化测试:Appium源码分析之跟踪代码分析四 控制器模块 // Appium webserver controller methods // https://github.com/hugs/a ...

  6. CTS(11)---android自动化测试CTS源码分析之一

    android自动化测试CTS源码分析之一 1, 概述 CTS(Compatibility Test Suite)全名兼容性测试,主要目的就是让Android设备开发商能够开发出兼容性更好的andro ...

  7. 集合底层源码分析之HashMap《上》(三)

    集合底层源码分析之HashMap<上>(三) 前言 源码分析 HashMap主要属性及构造方法分析 tableSizeFor()方法源码分析 Node类源码分析 TreeNode类源码分析 ...

  8. Android之AsyncTask源码分析(第五篇:execute方法只能执行一次的原因)

    (注意:本文基于API 28的源码分析,API 29上或其他平台的源码略有不同) 前言 当你调用AsyncTask对象的execute()方法时,突然发生崩溃--内心充满不解:java.lang.Il ...

  9. GDB 源码分析系列文章五:动态库延迟断点实现机制

    系列文章: GDB 源码分析系列文章一:ptrace 系统调用和事件循环(Event Loop) GDB 源码分析系列文章二:gdb 主流程 Event Loop 事件处理逻辑详解 GDB 源码分析系 ...

  10. app自动化测试之Appium 源码分析

    Appium 是由 Node.js 来实现的 HTTP 服务,它并不是一套全新的框架,而是将现有的优秀的框架进行了集成,在 Selenium WebDriver 协议(JsonWireProtocol ...

最新文章

  1. 语义分割 DeepLabv3--Rethinking Atrous Convolution for Semantic Image Segmentation
  2. 《LeetCode力扣练习》剑指 Offer 25. 合并两个排序的链表 Java
  3. 你还记得当初为什么进入IT行业吗?
  4. 全球及中国操纵杆控制系统行业应用动态与十四五形势分析报告2022版
  5. idea 编译显示source1.3不支持泛型(请使用source5或更高版本)
  6. Spring Cloud Config 规范 1
  7. 【note】软件体系结构(6-10章)
  8. deepin系统15.6版本安装执行那个exe文件_深度操作系统 deepin 20(1003)正式版发布:计算器支持科学计算,新增邮件、相机等应用...
  9. Java框架之SpringMVC 05-拦截器-异常映射-Spring工作流程
  10. mysql中show status介绍一
  11. oracle在线重定义表分区,oracle把一张表在线重定义成分区表
  12. 某医院病房计算机管理数据库,毕业论文_数据库某医院病房计算机系统.doc
  13. python实现遗传算法实例_vn.py发布v2.0.3 - 遗传算法
  14. 天龙源码框架分析_天龙八部源码描述【转】
  15. Gmail邮箱登陆问题解决方案
  16. 自动驾驶词汇概念介绍
  17. python期货基本面分析_Python股票期货交易利器,砖型图详细绘制教程!
  18. Entertain Box multiset的应用
  19. GridView使用【GridViewHelper】分组统计
  20. ios手机页面滑动卡顿问题

热门文章

  1. 深度学习中的“卷积”与数学中的“卷积”有何不同
  2. 隐马尔可夫模型通俗导论
  3. 海量数据挖掘MMDS week2: 局部敏感哈希Locality-Sensitive Hashing, LSH
  4. linux命令:常用shell命令及应用
  5. kali怎么进入root用户_ubuntu系统密码忘了怎么办(root或一般用户)
  6. 力扣-389 找不同
  7. MTK平台调试mipi屏问题小结
  8. MFC编码注意(2)
  9. Python 的解释器
  10. 深入理解Yii2.0(yii学习的经典博客)