使用appium-android滚动到页面末尾
问题描述:
对于混合应用程序,我需要滚动到页面末尾.我能怎么做 ? 我可以使用driver.scrollTo()滚动到确切的元素;和driver.ScrollToExact();
For a hybrid app , I need to scroll till the end of the page. How can I do ? I am able to scroll to exact element by using driver.scrollTo(); and driver.ScrollToExact();
但是我想从顶部到底部滚动应用程序. 有人可以告诉我吗?
But I want to scroll the app from top to bottom. Can anyone tell me please?
答
@Test
public void testScroll()throws Exception
{
for(int i=0;i<4;i++)
{
Thread.sleep(2000);
if (driver.findElement(By.name("end_item")).isDisplayed())
{
driver.findElement(By.name("end_item")).click();
break;
}
else
{
verticalScroll();
}
}
}
public void verticalScroll()
{
size=driver.manage().window().getSize();
int y_start=(int)(size.height*0.60);
int y_end=(int)(size.height*0.30);
int x=size.width/2;
driver.swipe(x,y_start,x,y_end,4000);
}
这将帮助您滑动到终点或您想要的任何位置.
This will help you to swipe till end or till whatever position you want.