Appium 1.6.3, How can I scroll to particular element in java

I am using appium 1.6.3, and IOSDriver, what are the ways available to scroll to the particular element on page


Appium version : 1.6.3
Desktop OS/version used to run Appium: 10.12 (16A323)
npm version : 3.10.9
Mobile platform/version under test: 10.0.2(14A456)
Real device or emulator/simulator: Real device

Use scrollTo or scrollToexact method.

those got deprecated

this is what we did in c# as a separate method to be called in any test suite

//Sleep needed in the cases of navigating away from a screen and coming back to. This gives the driver a chance to catch up.
//UiSelector arguments must only call “scrollIntoView” method or methods on UIScrollable whcih return UiScrollable or UiObject objects
return driver.FindElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches(”" + selector + “”).instance(0))"));
//Added because sometimes Android doesn’t scroll all the way
IWebElement frame = driver.FindElements(By.ClassName(“android.widget.ListView”)).ElementAt(0);
int startx = frame.Location.X + (frame.Size.Width / 2);
int starty = frame.Location.Y + ((frame.Size.Height / 2) - 5);
int endx = startx;
int endy = starty -100;
driver.Swipe(startx, starty, endx, endy, 400);

                return driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textMatches(\"" + selector + "\").instance(0))"));

below code works for me
((AppiumDriver) driver).scrollToExact(“Text”);

@er.pradeep4 what version of appium are you using?

I am using IOSDriver and appium version 1.6.3 with java - scrollTo or scrollToExact(“Text”); are no more supported.

Solution What I found is -

WebElement abc = driver.findElement(MobileBy.AccessibilityId(locator));

int x = abc.getLocation().getX();
int y = abc.getLocation().getY();

TouchAction action = new TouchAction(driver);,y).moveTo(x+90,y).release().perform();

in case any body need,

It works well, Thank You!!!

1 Like


I tried implementing your solution but it just scrolls up, and not down as I expect. I also tried increasing the pixels, and changing the plus to minus as i assumed it will change the direction but it did not. Could you please help me with this ?



Nevermind! I used driver.swipe() to get what I wanted. Thank you!

1 Like

Hi Schumin,

May u share with me your solution? Currently i can not work with “Scroll to Element”. Thank you.


This is what I created to use throughout my test suite.

public static void scrollToElement(IOSDriver driver,String elementName1, String elementName2) {
WebElement abc = driver.findElement(;
WebElement abc2 = driver.findElement(;
int x = abc.getLocation().getX();
int y = abc.getLocation().getY();
int x1 = abc2.getLocation().getX();
int y1 = abc2.getLocation().getY();
driver.swipe(x1, y1, x, y, 1);

Basically, Element 1 is an element that is visible on the screen somewhere at the top and Element 2 is visible on the screen somewhere towards the bottom.

Hope this helps!


Try the below method, one which works from version 3.0.0 to the latest 4.1.2
Ex: java-client 4.1.2

String selector = “searchString”;
driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector()).scrollIntoView(new UiSelector().text(”"+selector+""));"));

The method will scroll in the page until it finds the string with ‘searchString’.

1 Like

hi can any one help me out that i have to scroll the page i used swipe method

dr.swipe(0, 20,20, 40, 1000);

but it is not working

i used

((AppiumDriver) driver).scrollToExact(“Text”); this one also but not working

Rini, have you tried the above method.
If not try out and let me know.
If yes, lets share the logs.

((AppiumDriver) driver).scrollToExact(“Text”);

i am using java language

hi @arun_mangan

FAILED: testregistration
at defaultproject.wataap.testregistration(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.testng.internal.MethodInvocationHelper.invokeMethod(
at org.testng.internal.Invoker.invokeMethod(
at org.testng.internal.Invoker.invokeTestMethod(
at org.testng.internal.Invoker.invokeTestMethods(
at org.testng.internal.TestMethodWorker.invokeTestMethods(
at org.testng.TestRunner.privateRun(
at org.testng.SuiteRunner.runTest(
at org.testng.SuiteRunner.runSequentially(
at org.testng.SuiteRunner.privateRun(
at org.testng.SuiteRunnerWorker.runSuite(
at org.testng.TestNG.runSuitesSequentially(
at org.testng.TestNG.runSuitesLocally(
at org.testng.TestNG.runSuites(
at org.testng.remote.RemoteTestNG.initAndRun(
at org.testng.remote.RemoteTestNG.main(

Default test
Tests run: 1, Failures: 1, Skips: 0

Default suite
Total tests run: 1, Failures: 1, Skips: 0

scrollTo() and scrollToExact() are not consistent thats why its deprecated in 1.7.0
so use swipe() method

On iOS, you can use the code below:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put(“direction”, “up”);
scrollObject.put(“xpath”, “//XCUIElementTypeStaticText[@name=“NAME”]”);
js.executeScript(“mobile: swipe”, scrollObject);

1 Like

Hi, can you please give a code-snippet on how to scroll using swipe method? Is it based on location or based on objects?

Found a solution at least for Android -

Use the below code snippet.

public void scrollDown() {
	    int pressX = driver.manage().window().getSize().width / 2;
	    int bottomY = driver.manage().window().getSize().height * 4/5;
	    int topY = driver.manage().window().getSize().height / 8;
	    int i = 0;
	    	isPresent = driver.findElements("urid")).size()>0;
	    		 we = driver.findElement("urid"));
	    	scroll(pressX, bottomY, pressX, topY);}
	    } while(i <= 4);

	private void scroll(int fromX, int fromY, int toX, int toY) {
	    TouchAction touchAction = new TouchAction(driver);
	    catch(WebDriverException wd){
	    touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();


This can be improved, this is just a raw material. :slight_smile: Let me know if it doesn’t work for Android.

Appium version - 1.7.2
Java Client - 5.0.2 - BETA