scrollTo method doesn't work

In my iOS app, there is an element named ‘foo’ that is several pages down in a scrollable panel. When I call driver.scrollTo(“foo”) it fails with the following exception. But I am able to call driver.findElement(By.name(“foo”) and it does find that element. What am I doing wrong?

Appium version: 1.5.3
Java version: 1.8.0_92
iOS version: 9.3.2

Caused by: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15.29 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 17:00:58’
System info: host: ‘xxx’, ip: ‘10.78.86.76’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.5’, java.version: ‘1.8.0_92’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [showIOSLog=true, recreateChromeDriverSessions=false, newCommandTimeout=3600, platformVersion=null, browserName=, platformName=iOS, udid=a0ed91fc4f6c5ee74f2b33b0b42fbf4fb1a837b3, version=null, deviceName=iPhone 6, fullReset=true, platform=iOS}, newCommandTimeout=3600, platformVersion=null, webStorageEnabled=false, locationContextEnabled=false, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=a0ed91fc4f6c5ee74f2b33b0b42fbf4fb1a837b3}]
Session ID: 111047e1-e529-4b24-9d7f-27fea7bd30ab
*** Element info: {Using=-ios uiautomation, value=.scrollToElementWithPredicate(“name CONTAINS ‘foo’”)}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:43)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:37)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.ios.IOSElement.execute(IOSElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.findElement(RemoteWebElement.java:198)
at io.appium.java_client.ios.IOSElement.findElementByIosUIAutomation(IOSElement.java:38)
at io.appium.java_client.ios.IOSElement.scrollTo(IOSElement.java:60)
at io.appium.java_client.ios.IOSElement.scrollTo(IOSElement.java:1)
at io.appium.java_client.ios.IOSDriver.scrollTo(IOSDriver.java:108)

Hi,

As per readme provided for java client 4.0 version, scrollTo and scrollToExact are deprecated.

What is the new way to scroll to an element in iOS then?

you can use swipe method.
like ((MobileElement)element).swipe(SwipeDirection.UP,100);

Thank you. I was able to use driver.swipe method to finish my test.

I am trying to swipe using below code:
((IOSElement)element).swipe(SwipeElementDirection.DOWN,100 );

But I am getting java.lang.NullPointerException. Any help?

Hi,

What if the element is not displayed on UI and it is presented at bottom of a list having more number of elements. Say, e.g. I’ve 200 contacts in our application. I need to scroll down up to the last 200th element based on String (text attribute value). How come this is possible?

Thanks,
Bhaskar.

Hi,

Could anyone suggest about this scroll to alternative.!!

Regards,
Vijay Bhaskar.

lets discuss & conclude in single thread If scrollTo is deprecated in java client 4.0, what is the alternative?