You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to disable autoscrolling in UICollectionView #1328
I've added a potentially relevant comment in #1316 (comment).
KIF implicitly tries to scroll table views and collection views to enumerate elements that are offscreen. This is to allow tests to be more robust and not try to reason about the scroll position of the views on the screen, because that state can often change as we interact with the app and can be hard to explicitly control. Some view elements aren't accessible in the view/accessibility hierarchy until the view has been scrolled to that position. We stopped being able to access those cells programmatically and needed to scroll the view to different positions as a workaround for assertions that Apple added and called out in issues #1007 (for UITableViews) and #1303 (for UICollectionViews). If no matching view is found for the predicate, we should scroll back to the original view position. Once a matching element has been found, if it must be tappable, then we try to scroll it into the visible region of the screen.
If you wanted to understand why KIF is performing a scroll for your app and test, you could try setting some breakpoints on the lines of code I linked above to try and reason about why KIF is performing a scroll. If you wanted to globally turn the autoscroll behavior off, you could probably subclass KIFUIViewTestActor and set disablingAutomaticScroll to true always.
I'd be happy to merge a PR that adds a static boolean property on KIFUITestActor that waitForAccessibilityElement:view:withElementMatchingPredicate:tappable: could use as its default value and KIFUIViewTestActor could use in its initializer for setting the initial value of disablingAutomaticScroll. In that case, we'd maybe want something that is in the inverse of usingCurrentFrame to allow scrolling on a one off basis. If you wanted to contribute, please include tests to exercise the functionality.
Activity
stanislavleonchik commentedon Apr 24, 2025
@justinseanmartin @danielbarela Will this issue be fixed any time soon?
justinseanmartin commentedon Apr 24, 2025
I've added a potentially relevant comment in #1316 (comment).
KIF implicitly tries to scroll table views and collection views to enumerate elements that are offscreen. This is to allow tests to be more robust and not try to reason about the scroll position of the views on the screen, because that state can often change as we interact with the app and can be hard to explicitly control. Some view elements aren't accessible in the view/accessibility hierarchy until the view has been scrolled to that position. We stopped being able to access those cells programmatically and needed to scroll the view to different positions as a workaround for assertions that Apple added and called out in issues #1007 (for UITableViews) and #1303 (for UICollectionViews). If no matching view is found for the predicate, we should scroll back to the original view position. Once a matching element has been found, if it must be tappable, then we try to scroll it into the visible region of the screen.
If you wanted to understand why KIF is performing a scroll for your app and test, you could try setting some breakpoints on the lines of code I linked above to try and reason about why KIF is performing a scroll. If you wanted to globally turn the autoscroll behavior off, you could probably subclass
KIFUIViewTestActorand set disablingAutomaticScroll to true always.I'd be happy to merge a PR that adds a static boolean property on
KIFUITestActorthatwaitForAccessibilityElement:view:withElementMatchingPredicate:tappable:could use as its default value andKIFUIViewTestActorcould use in its initializer for setting the initial value ofdisablingAutomaticScroll. In that case, we'd maybe want something that is in the inverse ofusingCurrentFrameto allow scrolling on a one off basis. If you wanted to contribute, please include tests to exercise the functionality.