java客户端v4.0中scrollTo和scrollToExact的替换

java客户端v4.0中scrollTo和scrollToExact的替换,java,android,scroll,appium,swipe,Java,Android,Scroll,Appium,Swipe,我正在使用java和appium为Android/iOS编写移动应用程序自动化测试用例 我已将appium版本从3.1.0升级到4.0.0。现在我不能使用scrollTo()和scrollToExact() Java客户端自述说明如下:- scrollTo()和scrollToExact()被弃用。它们将在下一版本中删除 除刷卡方法和 像 是否有人知道替换scrollTo和scrollToExact的任何可能方法?在Appium的讨论板上查看 基本上,旧的滚动方法仍然可用(Android/iOS

我正在使用java和appium为Android/iOS编写移动应用程序自动化测试用例

我已将appium版本从3.1.0升级到4.0.0。现在我不能使用scrollTo()和scrollToExact()

Java客户端自述说明如下:-
scrollTo()
scrollToExact()
被弃用。它们将在下一版本中删除

除刷卡方法和 像

是否有人知道替换
scrollTo
scrollToExact
的任何可能方法?

在Appium的讨论板上查看


基本上,旧的滚动方法仍然可用(Android/iOS ui automator);这意味着您可以创建自己的助手以满足您的精确需求。

此方法不受欢迎,因为它不一致,将被删除。这实际上是一种变通办法。
建议改为使用:

AppiumDriver.swipe(int, int, int, int, int)
MobileElement.swipe(SwipeElementDirection, int)   
MobileElement.swipe(SwipeElementDirection, int, int, int) 
或者使用

MobileBy.ByAndroidUIAutomator
指定人:

scrollTo in interface ScrollsTo<org.openqa.selenium.WebElement>
从接口复制的说明:
触摸屏快捷按钮
在屏幕上滑动的便捷方法

参数:
startx-起始x坐标。
起始-起始y坐标。
endx-结束x坐标。
endy-结束y坐标。
duration—整个刷卡操作要执行的时间量(以毫秒为单位)

示例:

 @Test
 public void swipingVertical() throws InterruptedException {
  //Get the size of screen.
  size = driver.manage().window().getSize();
  System.out.println(size);

  //Find swipe start and end point from screen's with and height.
  //Find starty point which is at bottom side of screen.
  int starty = (int) (size.height * 0.80);
  //Find endy point which is at top side of screen.
  int endy = (int) (size.height * 0.20);
  //Find horizontal point where you wants to swipe. It is in middle of screen width.
  int startx = size.width / 2;
  System.out.println("starty = " + starty + " ,endy = " + endy + " , startx = " + startx);

  //Swipe from Bottom to Top.
  driver.swipe(startx, starty, startx, endy, 3000);
  Thread.sleep(2000);
  //Swipe from Top to Bottom.
  driver.swipe(startx, endy, startx, starty, 3000);
  Thread.sleep(2000);
 }
这对于新版本的Java Client 4.0执行您的Appium脚本来说无疑是可行的

问候:
高拉夫小子

public abstract void swipe(int startx, int starty, int endx, int endy, int duration)
 @Test
 public void swipingVertical() throws InterruptedException {
  //Get the size of screen.
  size = driver.manage().window().getSize();
  System.out.println(size);

  //Find swipe start and end point from screen's with and height.
  //Find starty point which is at bottom side of screen.
  int starty = (int) (size.height * 0.80);
  //Find endy point which is at top side of screen.
  int endy = (int) (size.height * 0.20);
  //Find horizontal point where you wants to swipe. It is in middle of screen width.
  int startx = size.width / 2;
  System.out.println("starty = " + starty + " ,endy = " + endy + " , startx = " + startx);

  //Swipe from Bottom to Top.
  driver.swipe(startx, starty, startx, endy, 3000);
  Thread.sleep(2000);
  //Swipe from Top to Bottom.
  driver.swipe(startx, endy, startx, starty, 3000);
  Thread.sleep(2000);
 }