appium 处理滑动的方法
appium 处理滑动的方法是 swipe(int start-x, int start-y, int end-x, int end-y, int during) - Method in class io.appium.java_client.AppiumDriver此方法共有5个参数,都是整形,依次是起始位置的x y坐标和终点位子的x y坐标和滑动间隔时间,单位毫秒坐标是指:屏幕左上角为坐标系原点(0,0),屏幕分辨率为终点坐标,比如你手机分辨率10801920,那么该手机坐标系的终点是(10801920),每个元素都在坐标系中,可以用坐标系定位元素。
比如这个登陆按钮在坐标系中的位置是起始点 + 终点(32,1040) (351,1152)
向上滑动向上滑动,就是从下到上,那么怎么进行从下到上的滑动呢?按照之前理解的坐标系,从上到下滑动,一般是垂直滑动,也就是X轴不变,Y轴从大变小的过程我们可以采取Y轴固定在屏幕正当中,Y轴滑动屏幕的1/2,Y轴的起始位置为屏幕的3/4,滑动终点为Y轴的1/4(尽量避免使用坐标系的起点和终点),滑动时间为1s,如果滑动时间过短,将会出现一次滑动多页。需要提醒的是,很多app运行的时候并不是全屏,还有系统自带工具栏和边框,一定要避免!!!
package com.java.driver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
//
public class CrazySwipe {
private AndroidDriver driver;
//
int x;
int y;
public CrazySwipe(AndroidDriver driver){
this.driver=driver;
this.x=driver.manage().window().getSize().getWidth();
this.y=driver.manage().window().getSize().getHeight();
}
public void swipeToUp(int duration){
driver.swipe(x/2, 7y/8, x/2, y/8, duration);
}
public void swipeToDown(int duration){
driver.swipe(x/2,y/8, x/2, 7y/8, duration);
}
public void swipeToLeft(int duration){
driver.swipe(7x/8,y/2, x/8, y/2, duration);
}
public void swipeToRight(int duration){
driver.swipe(x/8,y/2, 7x/8, y/2, duration);
}
public void swipe(String direction,int duration){
switch (direction.toLowerCase()) {
case "up":
this.swipeToUp(duration);
break;
case "down":
this.swipeToDown(duration);
break;
case "left":
this.swipeToLeft(duration);
break;
case "right":
this.swipeToRight(duration);
break;
default:
System.out.println("方向参数不正确,需传入up/down/left/right");
break;
}
}
}
appium 处理滑动的方法的更多相关文章
- appium 元素定位find_element_by_android_uiautomator方法使用
若appium中给定的方法无法满足你的需求,刚好uiautomator中的方法可以满足你的需求时,你可使用find_element_by_android_uiautomator来调用uiautomat ...
- 根据bootstrap框架实现移动端触摸滑动的方法
有一个移动端的项目要求用jquery+bootstrap,其中有一个轮播图,需求是要求可以手触滑动,但是bootstrap中没有写手触滑动的方法,自己琢磨着写了出来,供大家参考. $(function ...
- Appium处理滑动方法是swipe
滑动API:Swipe(int start x,int start y,int end x,int y,duration) 解释: int start x-开始滑动的x坐标:int start y - ...
- Appium scroll 滑动查找
首先看uiautomator如何实现滑动查找 UiScrollable scrollView = new UiScrollable(new UiSelector().className("a ...
- Python&Appium实现滑动引导页进入APP
最近在研究安卓APP的自动化测试.首先遇到的问题是,当一个session建立的时候,最先进入的是欢迎页和引导页,引导页有三张,最后一张上显示"enter"按钮,点击才能进入主界面. ...
- Appium 三种wait方法(appium 学习之改造轮子)
前些日子,配置好了appium测试环境,至于环境怎么搭建,参考:http://www.cnblogs.com/tobecrazy/p/4562199.html 知乎Android客户端登陆:htt ...
- appium 版本更新后的方法变化更新收集 ---持续更新
在高版本的android手机(例如android 7.0 , 8.0等等),必须使用高版本的appium, 以及对应的selenium版本,那么很多的appium或者selenium方法会变得无法直接 ...
- appium java 滑动(js滑动和swipe滑动)
最近有一个页面的内容很多,有的元素需要滑动到底部才能看到,所以就研究一下滑动,下面是我学习到的两种滑动方式 一:用js滑动 用js滑动的思路是很简单,首先是先定位到这个元素,定位到之后不做任何操作,然 ...
- appium手机键盘实现方法
首先引入appium的webdriver from appium import webdriver 方法1 AppiumDriver实现了在上述功能,代码如下(java版本) driver.sendK ...
随机推荐
- 剑指Offer——扑克牌顺子
题目描述: LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他 ...
- Centos7下实现免密码登录
一.生成密钥 [root@master ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to sa ...
- 现有mysql加入redis
spring-dao.xml(注意这里必须加上ignore-unresolvedable): redis.properties: redis.hostname=192.168.1.3 redis.po ...
- 001-hive是什么
一.基本概念 官网含义:https://cwiki.apache.org/confluence/display/Hive/Home The Apache Hive™ data warehouse so ...
- Linux下修改.bash_profile 文件改变PATH变量的值
Linux中含有两个重要的文件 /etc/profile和$HOME/.bash_profile 每当系统登陆时都要读取这两个文件,用来初始化系统所用到的变量,其中/etc/profile是超级用户所 ...
- js如何转义和反转义html特殊字符
“<”如何反转义为“<”,“>”如何反转义为“>”,下面就介绍如何用js来实现这种类似的操作. //HTML转义 function HTMLEncode(html) { var ...
- my first ai application
正式下手之前,先跑个demo体验以下. 1.my first ai application https://sonnguyen.ws/first-ai-application/ https://git ...
- IPFS搭建&集群
下载go-ipfs wget https://github.com/ipfs/go-ipfs/releases/download/v0.4.17/go-ipfs_v0.4.17_linux-amd64 ...
- Java应用程序中System.out.println输出中文乱码
其实,解决办法比较简单,即:编译时指定编码为UTF-8,如: javac -encoding utf- HelloJava.java 这样,再运行时就不会出现乱码. 比较详细的内容可以参考:http: ...
- PKU 2513 Colored Sticks(并查集+Trie树+欧拉路径(回路))
题目大意: 给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相连接的一端必须是同颜色的. 解题思路: 可以用图论中欧拉路的知识来解这道题,首先可以把木棒两端看成节点 ...