try{
List<WebElement> el=driver.findElements(xpath);
System.out.println("No of elements: "+el.size());
int a,b,c;
element=(MobileElement)el.get(0);
int topY = element.getLocation().getY();
int bottomY = topY + element.getSize().getHeight();
int centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
/*if(topY<0){
element=(MobileElement)el.get(1);
topY = element.getLocation().getY();
bottomY = topY + element.getSize().getHeight();
centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
}*/
if(topY<0)
topY=50;
if(bottomY>driver.manage().window().getSize().height)
bottomY=driver.manage().window().getSize().height-50;
// System.out.println("topY="+topY);
// System.out.println("bottomY="+bottomY);
// System.out.println("centerX="+centerX);
driver.swipe(centerX, bottomY, centerX, topY, duration);
if (bottomY-topY<=50){
bottomY=driver.manage().window().getSize().height-50;
topY=bottomY-50;
}
driver.swipe(centerX, bottomY, centerX, topY, duration);
}catch(Exception e){
System.out.println("Exception occurred while swipeing up");
}
List<WebElement> el=driver.findElements(xpath);
System.out.println("No of elements: "+el.size());
int a,b,c;
element=(MobileElement)el.get(0);
int topY = element.getLocation().getY();
int bottomY = topY + element.getSize().getHeight();
int centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
/*if(topY<0){
element=(MobileElement)el.get(1);
topY = element.getLocation().getY();
bottomY = topY + element.getSize().getHeight();
centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
}*/
if(topY<0)
topY=50;
if(bottomY>driver.manage().window().getSize().height)
bottomY=driver.manage().window().getSize().height-50;
// System.out.println("topY="+topY);
// System.out.println("bottomY="+bottomY);
// System.out.println("centerX="+centerX);
driver.swipe(centerX, bottomY, centerX, topY, duration);
if (bottomY-topY<=50){
bottomY=driver.manage().window().getSize().height-50;
topY=bottomY-50;
}
driver.swipe(centerX, bottomY, centerX, topY, duration);
}catch(Exception e){
System.out.println("Exception occurred while swipeing up");
}
No comments:
Post a Comment