【发布时间】:2017-01-01 00:27:02
【问题描述】:
如何使用 appium 在 Android 应用程序中将滚动条滑动到底部?
我尝试使用
driver.swipe(300,800,300,500,2);
driver.scrollTo("string")
但以上没有帮助。谁能建议我一些通用的解决方案?
【问题讨论】:
如何使用 appium 在 Android 应用程序中将滚动条滑动到底部?
我尝试使用
driver.swipe(300,800,300,500,2);
driver.scrollTo("string")
但以上没有帮助。谁能建议我一些通用的解决方案?
【问题讨论】:
一般的解决方案是使用尺寸进行滚动。使用下面的代码
public void scroll() throws IOException {
try {
Dimension dimensions = driver.manage().window().getSize();
System.out.println("Size of screen= " +dimensions);
int Startpoint = (int) (dimensions.getHeight() * 0.5);
System.out.println("Size of scrollStart= " +Startpoint );
int scrollEnd = (int) (dimensions.getHeight() * 0.2);
System.out.println("Size of cscrollEnd= " + scrollEnd);
driver.swipe(0, Startpoint,0,scrollEnd,1000);
} catch (IOException e) {
}
}
将此添加到您的代码中并简单地使用 scroll();在你的测试用例中。修改代码中给出的十进制值以满足您的要求
【讨论】: