appiun 滑动的简单封装
import java.io.File;
import java.io.IOException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
/*
? jar 使用的是 java-client-5.0.3 版本的,所以老版本的 swipe 方法是不能使用的!
? sleep_own()是自己封装的,读者可自行封装一个!
*/
public class Login extends KeyClass implements BaseExecuteInterface{
public Login(){}
public AndroidDriver<WebElement> driver;
public ?final String up = "up";
public final String down="down";
public final String left="left";
public final String right="right";
public ?void direct_slide_f(String direct){
TouchAction touchAction =new TouchAction(driver);
if(direct.equals(this.getUp())){?? ??
touchAction.longPress(360, 720).moveTo(360, 600).release().perform();
System.out.println(up);
sleep_own(3);
}else if(direct.equals(this.getDown())){
//TouchAction touchAction =new TouchAction(driver);
touchAction.longPress(360, 600).moveTo(360, 720).release().perform();
sleep_own()(3);
}else if(direct.equals(this.getRight())){
//TouchAction touchAction =new T 《一线大厂 Java 面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》无偿开源 威信搜索公众号【编程进阶路】 ouchAction(driver);
touchAction.longPress(360, 600).moveTo(460, 600).release().perform();
sleep_own()(3);
}else if(direct.equals(this.getLeft())){
//TouchAction touchAction =new TouchAction(driver);
touchAction.longPress(460, 600).moveTo(360, 600).release().perform();
sleep_own()(3);
}else {
System.out.println("参数错误");
sleep_own(3);
}
}
}
赋上 maven 的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yuedu</groupId>
<artifactId>pineapple</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>pineapple</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
评论