对于混合应用程序,我需要滚动到页面的末尾。我该怎么做呢?我可以使用driver.scrollTo()和driver.ScrollToExact()滚动到确切的元素;
但我想从上到下滚动这个应用程序。有人能告诉我吗?
发布于 2016-03-01 17:40:49
@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);
}这将帮助你滑动直到结束或直到任何你想要的位置。
发布于 2015-10-19 21:47:11
您可以使用坐标滚动到页面的末尾,甚至可以定位页面上可用的字符串。使用以下命令:
TouchAction action = new TouchAction(driver).longPress(20,y).moveTo(20, 10).release();
action.perform();发布于 2015-10-19 21:00:12
我也有同样的问题。我所做的是,使用该特定页面("text should be dynamic, it should be constant")底部的文本,然后使用以下代码
String text="ABC";
driver.scrollTo(text);在此代码之后,您可以执行任何操作。例如,请参阅以下代码
String text="ABC";
driver.scrollTo(text);
driver.findElement(By.xpath("//*[@text='"+text+"']")).click();https://stackoverflow.com/questions/33212411
复制相似问题