How to scroll a dynamic data screen upto the bottom and back to the top of the screen in native ios app

Hi Guys,

I’m facing issue in scrolling a dynamic data screen upto the bottom and back to the top of the screen in native ios app.

Here its UIATableView.

scrollTo(), scrollToExact() methods cant be used because the data is dynamic and every time its changes

Try - 1
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put(“direction”, “down”);
js.executeScript(“mobile: scroll”, scrollObject);

Try - 2
Also tried swipe but unable to scroll it
int topY = element.getLocation().getY();
int bottomY = topY + element.getSize().getHeight();
//int centerX = element.getLocation().getX() + (element.getSize().getWidth()/2);
driver.swipe(0, bottomY, 0, topY, 2000);

By using try - 1 I’m able to scroll screen some what down but not totally to the bottom and up

Please help me in resolving this issue.

Thanks in advance.

You can use the below code for scroll till the text appear:

//Capture all the list items

	AndroidElement list = (AndroidElement)driver.findElementById("EnterdTheYourElementId");
	
	//Scrolling down till Xyz Text found		
	
	MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
	        "new UiScrollable(new UiSelector().scrollable(true))" +
	         ".scrollIntoView(new UiSelector().textContains(\"Xyz Text\"))"));