iOS 7.1 Simulator and Appium 1.3.4 scrollTo and Swipe not working

Running on OSX 10.9.5 with Xcode 6.1, using an iOS 7.1 simulator, writing my tests in Java, and using Appium 1.3.4 and I think Java-client 2.1.0.

This used to work wonderfully and the tests completed perfectly. Ever since the release of Xcode 6.1 and iOS 8.1, however, it has not at all, even after Appium updates. (Nevermind that testing on an iOS 8.1 simulator doesn’t even get far enough to get to the scrolling code.)

I’ve tried using driver.scrollTo(“label”), driver.scrollToExact(“label”), and driver.swipe() to find an element outside of the current frame in my app. I used to use a wrapper function that somebody else wrote who initially created the tests that I inherited, which would call swipe and calculate how to move based on an xpath passed to it. But that doesn’t work, so I tried calling the three methods directly and still nothing. Now nothing visually happens and all of my tests fail on the next line (so the scroll action itself supposedly doesn’t fail…) - which checks that an element is displayed by xpath. Which they aren’t, because it won’t scroll.

I’ve not been able to find anything that actually fixes this problem for me and could really use some help…

I had the same problem, but with the iOS 8.3 simulator and Appium 1.4.0. The solution that worked for me came from the docs: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/touch-actions.md

For my test the user selects an item from the main menu, and then after arriving at the next page, scrolls all the way down to the last list item on the page. My tests are written in Java, and this is the exact code that I used to scroll down to the last list item on the page:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);

It’s not a very long list that I’m scrolling through so I don’t know how this would work if the list were 50 items long, for example. The code above gets me far enough down the list that I can then locate the list item that I want and click on it.

I hope this helps.

1 Like

Thank you. The Javascript solution works!

1 Like