自动化-滑屏功能用例

package com.comm.util;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

/**
 * 封装了一些方法 1.滑屏
 * @param driver(把appiudriver对象传进来)
 * @param during(这里是填写毫秒数,这里的毫秒数越小 滑动的速度越快~ 一般设定在500~1000,如果你想快速滑动 那就可以设置的更加小)
 * @param num(是只滑动的次数,本人在做相册 翻页测试什么的 滑动 或者滑动到列表底部。就直接输入次数就行了)
 * @throws InterruptedException
 * @author jff
 */
public class SlipScreen {
	public static void swipScreen(AndroidDriver<AndroidElement> driver,int duration,int num) throws InterruptedException{
		int width=driver.manage().window().getSize().width;
		int height=driver.manage().window().getSize().height;
		System.out.println(width);
		System.out.println(height);
		for(int i=0;i<num;i++){
			driver.swipe(width/2, height*3/4, width/2, height/4, duration);
			Thread.sleep(1000);
		}
	}
	
	//测试代码
	//SlipScreen.swipScreen(driver, 800, 1);
}

猜你喜欢

转载自blog.csdn.net/jffhy2017/article/details/68944640