使用 appium-android 滚动到页面末尾 [英] Scroll till end of the page using appium-android
本文介绍了使用 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.
这篇关于使用 appium-android 滚动到页面末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文