appium移动端测试之滑动(二)
在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移动端测试之滑动(二)的更多相关文章
- 移动端触摸滑动插件Swiper
移动端触摸滑动插件Swiper 04/02/2015 一.了解Swiper 目前移动端项目一般都需要具有触屏焦点图的效果,如果你也需要实现这一功能的话,Swiper是一个不错的选择. 1.他不需要加载 ...
- 移动端tab滑动和上下拉刷新加载
移动端tab滑动和上下拉刷新加载 查看demo(请在移动端模式下查看) 查看代码 开发该插件的初衷是,在做一个项目时发现现在实现移动端tab滑动的插件大多基于swiper,swiper的功能太强大而我 ...
- 原生 JS 实现移动端 Touch 滑动反弹
什么是 Touch滑动?就是类似于 PC端的滚动事件,但是在移动端是没有滚动事件的,所以就要用到 Touch事件结合 js去实现,效果如下: 1. 准备工作 什么是移动端的 Touch事件?在移动端 ...
- 【css】用css巧妙实现移动端横向滑动展示功能
前言:记得以前处理移动端横向滑动展示都是去用js去解决的,要用js进行蛮多处理,要算li的宽度,然后还要用js设置ul盒子的宽度,又要设置最大滑动距离,最小滑动距离等等.......但是现在发现用cs ...
- appium移动端自动化测试环境搭建windows-appium-android
第一步:安装jdk 安装jdk(1.7版本以上) 安装完成设置jdk环境变量(百度查询) cmd命令下键入 java -version命令检查jdk是否安装成功且设置环境变量成功,如下图所示: 第二步 ...
- 用css巧妙实现移动端横向滑动展示功能
前言:记得以前处理移动端横向滑动展示都是去用js去解决的,要用js进行蛮多处理,要算li的宽度,然后还要用js设置ul盒子的宽度,又要设置最大滑动距离,最小滑动距离等等.......但是现在发现用cs ...
- swiper嵌套小demo(移动端触摸滑动插件)
swiper(移动端触摸滑动插件) tip:自己敲得Swiper 的小demo,可以复制粘贴看看效果哦. swiper的js包css包下链接地址 : https://github.com/Clear ...
- 自己用原生JS写的轮播图,支持移动端触摸滑动,分页器圆点可以支持mouseover鼠标移入和click点击,高手看了勿喷哈
自己用原生JavaScript写的轮播图,分页器圆点按钮可支持click点击,也可支持mouseover鼠标悬浮触发,同时支持移动端触摸滑动,有兴趣的友友可以试试哈,菜鸟一枚,高手看了勿喷,请多多指正 ...
- 单元测试之NUnit二
NUnit 分三篇文章介绍,入门者可阅读文章,有基础者直接参考官方文档.初次写博客,望大家指点. 导航: 单元测试之NUnit一 单元测试之NUnit二 单元测试之NUnit三 本文介绍常用的NUni ...
随机推荐
- jade转化为html
网址:http://www.html2jade.org/ 刚到一家新的公司 ,上一个前段PHP写的代码基本都是jade写的,看的一脸懵逼,第一次遇到jade代码,并且我一直用的是atom开发工具,安装 ...
- Python实例2
2.企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%:20万到40万之间 ...
- Spark RDD
对RDD的学习进行一下整理 RDD:基于内存的集群计算容错抽象 分布式内存抽象的概念---弹性分布式数据集(RDD),它具备MapReduce等数据流模型的容错特性,并且允许开发人员在大型集群上执行基 ...
- coderforces #387 Servers(模拟)
Servers time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- ACM water
1000 纯属适应题 1003 做的时候花了很久,现在看好像也不难 1004 适应题,求下平均就行 1005 要读懂题就行 1007 逆序数,discuss方法 1046 全部暴搜一遍.. ...
- c# List的排序
list 是我们常用到的数据类型,我们常常会用list去处理很多的数据.我们也常常会有这样的一个操作,就是排序sort list 所在的命名空间是System.Collections.Generic ...
- eclipse安装反编译工具
身为一名程序员来说,日常最常做的就是编写代码和查看别人写好的源代码了,有时候打开别人写的class文件发现根本不是自己想要的,所以给大家介绍一种eclipse中反编译class文件的工具. 第一步:下 ...
- Discuz模拟批量上传附件发帖
简介 对于很多用discuz做资源下载站来说,一个个上传附件,发帖是很繁琐的过程.如果需要批量上传附件发帖,就需要去模拟discuz 上传附件的流程. 模拟上传 discuz 附件逻辑 dz附件储存在 ...
- C# List 的一些操作 (两List元素是否想同,List是否包含在另一个List中)
一. 假设有两个List<T>对象 ,List1和List2,如下方法判断两个List是否相等 List1.All(List2.Contains) && List1.Cou ...
- kubernetes多节点部署解析
注:以下操作均基于centos7系统. 安装ansible ansilbe可以通过yum或者pip安装,由于kubernetes-ansible用到了密码,故而还需要安装sshpass: pip in ...