在ios测试中,需要用到滑动,所以用java封装了一套滑动的方法,不多说,贴代码

/**
* 上滑1/4屏幕
*/
public void slideUP1_4() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 2, y / 3 * 2, x / 2, y / 3 * 1, 0);
} /**
* 上滑1/2屏幕
*/
public void slideUP1_2() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 2, y / 4 * 3, x / 2, y / 4 * 1, 0);
} /**
* 下滑1/4屏幕
*/
public void slideDown1_4() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 2, y / 3 * 1, x / 2, y / 3 * 2, 0);
} /**
* 下滑1/2屏幕
*/
public void slideDown1_2() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 2, y / 4 * 1, x / 2, y / 4 * 3, 0);
} /**
* 左滑1/2屏幕
*/
public void slideLeft1_2() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 4 * 3, y / 2, x / 4 * 1, y / 2, 0);
} /**
* 左滑2/3屏幕
*/
public void slideLeft2_3() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 3 * 2, y / 2, 0, y / 2, 0);
} /**
* 右滑1/2屏幕
*/
public void slideRight1_2() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 4 * 1, y / 2, x / 4 * 3, y / 2, 0);
} /**
* 右滑2/3屏幕
*/
public void slideRight2_3() {
int x = driver.manage().window().getSize().width;
int y = driver.manage().window().getSize().height;
driver.swipe(x / 3 * 1, y / 2, x, y / 2, 0);
} /**
* 在某元素中滑动向上滑动
*
* @param 传入WebElement
*/
public void slideUP(WebElement a) {
int x = a.getSize().width;
int y = a.getSize().height;
driver.swipe(x / 10, y / 3 * 2, x / 10, y / 3 * 1, 0); } /**
* 在某元素中滑动向下滑动
*
* @param 传入WebElement
*/
public void slideDown(WebElement a) {
int x = a.getSize().width;
int y = a.getSize().height;
driver.swipe(x / 10, y / 3 * 1, x / 10, y / 3 * 2, 0);
} /**
* 在某元素中滑动向左滑动
*
* @param 传入WebElement
*/
public void slideLeft(WebElement a) { int x = a.getSize().width;
int y = a.getSize().height;
driver.swipe(x / 4 * 3, y / 10, x / 4 * 2, y / 10, 0);
} /**
* 在某元素中滑动向右滑动
*
* @param 传入 Webelement
*/
public void slideRight(WebElement a) {
int x = a.getSize().width;
int y = a.getSize().height;
driver.swipe(x / 4 * 2, y / 10, x / 4 * 3, y / 10, 0);
} /**
* 长按某元素
*
* @param 传入WebElement
* @param 传入时间 ms
*
*/
public void longpress(WebElement el, int duration) {
TouchAction action = new TouchAction(driver);
action.longPress(el, duration);
} /**
* 将某元素拖动至另一元素
*
* @param 传入WebElement
*/
public void touch_webelement_to_other_webelement(WebElement e1, WebElement e2) {
TouchAction action = new TouchAction(driver);
action.longPress(e1).moveTo(e2);
}

appium移动端测试之滑动(二)的更多相关文章

  1. 移动端触摸滑动插件Swiper

    移动端触摸滑动插件Swiper 04/02/2015 一.了解Swiper 目前移动端项目一般都需要具有触屏焦点图的效果,如果你也需要实现这一功能的话,Swiper是一个不错的选择. 1.他不需要加载 ...

  2. 移动端tab滑动和上下拉刷新加载

    移动端tab滑动和上下拉刷新加载 查看demo(请在移动端模式下查看) 查看代码 开发该插件的初衷是,在做一个项目时发现现在实现移动端tab滑动的插件大多基于swiper,swiper的功能太强大而我 ...

  3. 原生 JS 实现移动端 Touch 滑动反弹

    什么是 Touch滑动?就是类似于 PC端的滚动事件,但是在移动端是没有滚动事件的,所以就要用到 Touch事件结合 js去实现,效果如下: 1. 准备工作 什么是移动端的 Touch事件?在移动端 ...

  4. 【css】用css巧妙实现移动端横向滑动展示功能

    前言:记得以前处理移动端横向滑动展示都是去用js去解决的,要用js进行蛮多处理,要算li的宽度,然后还要用js设置ul盒子的宽度,又要设置最大滑动距离,最小滑动距离等等.......但是现在发现用cs ...

  5. appium移动端自动化测试环境搭建windows-appium-android

    第一步:安装jdk 安装jdk(1.7版本以上) 安装完成设置jdk环境变量(百度查询) cmd命令下键入 java -version命令检查jdk是否安装成功且设置环境变量成功,如下图所示: 第二步 ...

  6. 用css巧妙实现移动端横向滑动展示功能

    前言:记得以前处理移动端横向滑动展示都是去用js去解决的,要用js进行蛮多处理,要算li的宽度,然后还要用js设置ul盒子的宽度,又要设置最大滑动距离,最小滑动距离等等.......但是现在发现用cs ...

  7. swiper嵌套小demo(移动端触摸滑动插件)

    swiper(移动端触摸滑动插件) tip:自己敲得Swiper 的小demo,可以复制粘贴看看效果哦. swiper的js包css包下链接地址 :  https://github.com/Clear ...

  8. 自己用原生JS写的轮播图,支持移动端触摸滑动,分页器圆点可以支持mouseover鼠标移入和click点击,高手看了勿喷哈

    自己用原生JavaScript写的轮播图,分页器圆点按钮可支持click点击,也可支持mouseover鼠标悬浮触发,同时支持移动端触摸滑动,有兴趣的友友可以试试哈,菜鸟一枚,高手看了勿喷,请多多指正 ...

  9. 单元测试之NUnit二

    NUnit 分三篇文章介绍,入门者可阅读文章,有基础者直接参考官方文档.初次写博客,望大家指点. 导航: 单元测试之NUnit一 单元测试之NUnit二 单元测试之NUnit三 本文介绍常用的NUni ...

随机推荐

  1. winfrom 限制文本框小数点后两位

    private void numWeight_KeyPress(object sender, KeyPressEventArgs e) { if (char.IsNumber(e.KeyChar) | ...

  2. 面试题---PHP

    1.PHP(外文名: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言. 2.echo,print和print_r的区别: echo和print都可以做 ...

  3. python之模块安装

    在python中,python官方提供了很多可以扩展的包,用以增强python的功能. 因为用到了excel的读写功能,需要安装xlrd的包,一下是安装步骤 1.首先从python的官方库下载相应的包 ...

  4. Object.create() 和 __proto__ 的关系

    经测试得出 Ojbect.create() 也就是通过修改 __proto__ 实现的. 例: var Super = { say: function() {console.log('say')} } ...

  5. java POI 解析excel 2003和2007 直接转为List<Map> 返回

    1.POI 官网下载jar包,3.5以上 2.项目导入jar包 3.参数:String数组--对应的excel列名对应的KEY,File  excel文件,sheetNumber ---excel的s ...

  6. 在Chrome+Visual Studio中调试asp.net程序很慢的问题(Firefox也有类似问题)

    在Chrome+Visual Studio中调试asp.net程序很慢的问题(Firefox也有类似问题) 今天开始起在Chrome中调试,发现问题主要出在菜单栏(layout文件)中,google了 ...

  7. UML基础与Rose建模实训教程

    目  录 第1章  初识UML. 1 1.1 初识UML用例图... 1 1.2 初识UML类图... 3 第2章  Rational Rose工具... 6 2.1 安装与配置Rational Ro ...

  8. Ubuntu14.04用apt在线/离线安装CDH5.1.2[Apache Hadoop 2.3.0]

    目录 [TOC] 1.CDH介绍 1.1.什么是CDH和CM? CDH一个对Apache Hadoop的集成环境的封装,可以使用Cloudera Manager进行自动化安装. Cloudera-Ma ...

  9. Fatal error 829---数据库 ID 8,页 (1:80740) 已标记为 RestorePending,可能表明磁盘已损坏(日志备份和热备、双机的重要性)

    问题现象: 在业务数据库中查询:SELECT a.NAME FROM SYSOBJECTS a WHERE a.NAME LIKE '%2015' AND a.XTYPE='u' 提示:消息 21,级 ...

  10. PHP list,explode的使用

    PHP list,explode的使用 <?php header("Content-type: text/html; charset=utf-8"); echo " ...