缥帙各舒散,前后互相逾。这篇文章主要讲述Appium 之上划下划,左划右划相关的知识,希望能为你提供帮助。
【Appium 之上划下划,左划右划】听说appium java-client 新版本不支持swipe了,网上没找到完整可用的,今天正好整理出用TouchAction替换的脚本,记录一下,嘻嘻……
import java.time.Duration; import io.appium.java_client.TouchAction; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.touch.WaitOptions; import io.appium.java_client.touch.offset.PointOption; public class SwipeClass {static Duration duration=Duration.ofSeconds(1); public void swipeToUp(AndroidDriver driver) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; TouchAction action1=new TouchAction(driver).press(PointOption.point(width/2, height*3/4)).waitAction(WaitOptions.waitOptions(duration)) .moveTo(PointOption.point(width/2, height/4)).release(); action1.perform(); } public void swipeToDown(AndroidDriver driver) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; TouchAction action2=new TouchAction(driver).press(PointOption.point(width/2, height/4)).waitAction(WaitOptions.waitOptions(duration)) .moveTo(PointOption.point(width/2, height*3/4)).release(); action2.perform(); }public void swipeToLeft(AndroidDriver driver) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; TouchAction action3=new TouchAction(driver).press(PointOption.point(width*3/4, height/2)).waitAction(WaitOptions.waitOptions(duration)) .moveTo(PointOption.point(width/4,height/2)).release(); action3.perform(); }public void swipeToRight(AndroidDriver driver) { int width = driver.manage().window().getSize().width; int height = driver.manage().window().getSize().height; TouchAction action4=new TouchAction(driver).press(PointOption.point(width / 4, height / 2)).waitAction(WaitOptions.waitOptions(duration)) .moveTo(PointOption.point(width*3/4,height/2)).release(); action4.perform(); }}
推荐阅读
- 008 @RequestMapping
- Pure.CSS Checkboxex和单选输入
- 如何使用Pure.CSS
- Pure.CSS对齐表单
- Primefaces教程介绍
- PrimeFaces提示工具组件用法
- PrimeFaces TabView组件用法
- 笔记本触摸板,图文详细说明怎样运用
- cf截图在啥地方个文件夹,图文详细说明cf截图保存在啥地方里