在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. Linux删除apt-get安装的软件

    我们都知道安装软件最简单的方法是apt-get install,但是卸载就不常用了,如何卸载呢?1.sudo apt-get remove xxxxxsudo apt-get autoremove2. ...

  2. android 7.0变化

    一.加强版的低电耗模式 条件:1未插电源:2屏幕关闭:(N与6.0的区别就在于N在手机非静止时也可进入低电耗模式) 作用过程及方式:1充电状态:2屏幕关闭一定时间:进入一级低电限制:关闭网络,推迟CP ...

  3. Jenkins的配置(rpm red hat方式)

    Jenkins的配置文件位置 #### sudo chown -R admin /usr/lib/jenkins sudo chgrp -R admin /usr/lib/jenkins #### s ...

  4. php 上传大文件配置upload_max_filesize和post_max_size选项

    php 上传大文件配置upload_max_filesize和post_max_size选项 (2014-04-29 14:42:11) 转载▼ 标签: php.ini upload _files[f ...

  5. 关于位图读取函数int Load_Bitmap_File的lseek问题。

    事情是这样的,本人在编译3D游戏编程大师技巧中的程序是遇到了一个关于位图读取函数int Load_Bitmap_File的lseek问题. 我使用以下位图读取函数读取位图事报错如下: int Load ...

  6. Sublime Text 添加eclipse快捷键

    [ // editor配置 { "keys": ["ctrl+v"], "command": "paste_and_indent& ...

  7. Spring源码学习之: 通过Spring @PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作

    关于在spring  容器初始化 bean 和销毁前所做的操作定义方式有三种: 第一种:通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作 第二 ...

  8. zabbix问题处理

    工作的时候回遇到各种各样的问题. 今天遇到一个关于zabbix的问题. "Zabbix agent on host.name is unreachable for 5 minutes&quo ...

  9. MYSQL file types redo log

    https://blogs.oracle.com/mysqlinnodb/entry/data_organization_in_innodb https://blogs.oracle.com/mysq ...

  10. hosts 文件妙用

        127.0.0.1  localhost  www.baidu.com  www.126.com  www.xiaoxiao.com 1: 如果在hosts文件中加入这句话,则localhos ...