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 ...
随机推荐
- Android开发教程:shape和selector的结合使用
shape和selector是Android UI设计中经常用到的,比如我们要自定义一个圆角Button,点击Button有些效果的变化,就要用到shape和selector.可以这样说,shape和 ...
- input 栏位光标末尾闪烁
var input1 =window.document.getElementById("input1").createTextRange(); input1.collapse(fa ...
- [C# WPF]MoeEroViewer Developing Log
[C# WPF]MoeEroViewer Developing Log 1st - Base Document run on Https://github.com/Amarillys/MoeEroVi ...
- JAVA文件下载功能问题解决日志
今天给报告系统做了个下载功能,遇到了挺多问题,通过查资料一一解决了. 1.首先遇到的问题是:java后台的输出流输出之后,没有任何报错,浏览器端不弹出保存文件的对话框,原本是ajax请求到后台的con ...
- MFC编程 | 非模态对话框的定义
因为课程需要,会用到MFC编程,所以讲一些经验总结下,以便日后使用查询. // 非模态对话框的定义 // 通过单文档菜单调用一个非模态窗口 1.首先在工程里插入一个对话框(如:IDD_DLG_TEST ...
- 对tomcat中使用反射加载类的理解
public void init() throws Exception { initClassLoaders(); //加载一下jar包和类 Thread.currentThread().setCon ...
- 【OpenGL】第二篇 Hello OpenGL
---------------------------------------------------------------------------------------------------- ...
- 【OpenGL】VAO与VBO
1.我们先了解什么是OpenGL对象(OpenGL Object) 根据OpenGL Wiki的定义: An OpenGL Object is an OpenGL construct that con ...
- Building good docker images
The docker registry is bursting at the seams. At the time of this writing, a search for "node&q ...
- Sqlite小数作差,会减不尽?
select 6307.65-5922.68 from CW_ZWMX 以上语句,在设Navigate中执行的结果是:384.969999999999 不解!!!