The Scroll Problem in iOS UI Tests and How XCScrollHelper Solves It
Article Summary
Dogancan Mavideniz from Trendyol reveals how his team cut iOS UI test execution time by 5x. The culprit? The way XCTest handles scrolling.
In e-commerce apps with long scrollable lists, UI tests spend most of their time waiting for swipe animations to complete. Trendyol's iOS team built XCScrollHelper, an open-source library that bypasses XCTest's swipe mechanism entirely by using file-based communication between test and app processes.
Key Takeaways
- Traditional swipe loops take 25 seconds per scroll; XCScrollHelper does it in 5 seconds
- Uses setContentOffset and layout attributes instead of simulating user swipes
- Deployed across 2,889 snapshot tests in production at Trendyol
- Built-in retry logic handles lazy-loaded cells and layout delays automatically
By replacing XCTest's animation-based scrolling with programmatic setContentOffset calls, XCScrollHelper achieves 5x faster test execution across thousands of snapshot tests.
About This Article
Trendyol's iOS team had trouble with unreliable scrolling in UI tests. Swipe distances varied depending on device size and dynamic type settings, so developers had to set maxSwipes very high just to handle the worst cases.
XCScrollHelper lets the app and test processes communicate through files. It uses UICollectionViewLayout's layoutAttributesForItem to find exact coordinates, then calls setContentOffset directly instead of simulating swipes.
Flaky test rates dropped because programmatic scrolling removed the variables that came from different devices and layouts. Developers also stopped needing boilerplate scroll code to reach components that were off-screen.