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 ...
随机推荐
- 【opencv】 solvepnp 和 solvepnpRansac 求解 【空间三维坐标系 到 图像二维坐标系】的 三维旋转R 和 三维平移 T 【opencv2使用solvepnp求解rt不准的问题】
参考: pnp问题 与 solvepnp函数:https://www.jianshu.com/p/b97406d8833c 对图片进行二维仿射变换cv2.warpAffine() or 对图片进行二维 ...
- PHP error_log 新认知
//error_log 简介及使用方法 // error_log("消息","类型","路径"); //message //type ...
- geo实现方案
1.数据库内在支持GIS(地理信息系统) MySQL: 目前只有MyISAM引擎是支持GIS的,Innodb在5.7版本中才支持空间索引.MyISAM这个引擎不支持事务.外键,而且是表锁.适合读为主, ...
- freemarker学习#1
在工作的过程中遇到了.ftl文件.打开发现里面是一些类似于html的代码,非常好奇这是一种什么样的文件,于是去网上搜了一下,了解到.ftl是Freemarker模板的文件后缀名.将问题转移到了Free ...
- GlusterFS部署
一.GlusterFS简介 PB级容量.高可用.读写性能.基于文件系统级别共享.分布式.无metadata(元数据)的存储方式. GlusterFS(GNU ClusterFile System)是一 ...
- 微信js-sdk使用
<?php $appid=""; $secret=""; class JSSDK { private $appId; private $appSecret ...
- ITL(Interested Transaction List)理解
一.ITL描述: ITL(Interested Transaction List)是Oracle数据块内部的一个组成部分,位于数据块头(block header),itl由xid,uba,flag,l ...
- Subime3 快捷键
实用快捷键 Ctrl+Shift+P:打开命令面板Ctrl+P:搜索项目中的文件Ctrl+G:跳转到第几行Ctrl+W:关闭当前打开文件Ctrl+Shift+W:关闭所有打开文件Ctrl+Shift+ ...
- [Python] logging.logger
<1>. mylogger = logging.getLogger("abc") logging.debug()/logging.info()/logging.warn ...
- django【F和Q】
一.F 案例每人增加500工资 ORM:UserInfo.objects.filter().update(salary=500) 这不行吧 SQL: update userinfo set salar ...