Hi @AshrafRizvi01,
I had the same thought and implemented below method.
//This method scrolls downwards / swipe upwards only
public void scroll(AppiumDriver driver,By by)
{
boolean found=false;
while(!found)
{
try
{
driver.findElement(by);
found=true;
}
catch(Exception e)
{
Dimension size = driver.manage().window().getSize();
int startx=size.width/2;
int starty=(int)(size.height*0.9);
int endx=size.width/2;
int endy=(int)(size.height*0.2);
driver.swipe(startx, starty, startx, endy, 1000);
}
}
}
We can call the method something like below, however we can implement this method with By or text etc…
By weBy=By.xpath(“xpath=//*[@text=‘foo’]”);
scroll(driver,weBy);
Is there a way that we can find out we scrolled end of the search list or something? Because the above logic works out as far as the search string/object exists. Incase if the object doesnt exists, and if we are at end of the list then we should throw that item not found.
Is there any better way handling the above?