kif-framework / KIF

Keep It Functional - An iOS Functional Testing Framework
Other
6.2k stars 909 forks source link

Fix bug with table view elements that are matched but offscreen #1251

Closed dostrander closed 2 years ago

dostrander commented 2 years ago

This re-introduces https://github.com/kif-framework/KIF/pull/1070 where elements off screen in a scrollview need to be scrolled before they are tapped.

In iOS 15 some elements in a tableview are within the scrollview though not on screen, specifically table view footers (not to be confused with table view section footers). This causes an element to be matched and "found" but untappable. Adding this will make sure that we scroll to the element before tapping it

babbage commented 2 years ago

This commit broke a substantial number of my tests, which used KIF to navigate the UI but also included snapshot testing. When tester().waitForView(withAccessibilityLabel: "My accessibility label") is called, following this commit any scroll view is scrolled to its bottom bounds, even where the item that is being waited for was already visible when the method was called. This results in scroll view displacement which in my case caused snapshot tests to fail as the new screenshots did not match with the expected baselines in many cases.

I also noticed the same problem in places where I had called tester().waitForAbsenceOfView(withAccessibilityIdentifier: "Title") where the scroll view is now being unexpectedly scrolled where previously it did not. This also has led to test failures and required me to re-write those tests.

I am removing these waitForView... calls as they no longer seem to be necessary for my tests to run reliably anyway, which was the reason they were originally added. I do wonder however about whether this commit has overshot its intention given what I have observed. It would seem to me that KIF should first attempt to ascertain if the view being requested is visible without scrolling and should only do this new auto-scrolling (if at all) when there is a problem with the first approach.

It may be I have not understood the original intentions of this patch... I did not attempt to take in the full picture, just enough to confirm this definitely appears to be the cause of many of my snapshot tests expectedly failing.

Edit: Hmm. I am using the 3.8.5 release I now realise, and this patch landed after that was released. Apologies for the mis-attribution. Perhaps this patch even fixes what I was observing. Let me know if I should be opening a new issue, or similar. :)

dostrander commented 2 years ago

@babbage What you are describing is a side effect of this PR. Which we've actually reverted here and are planning to cut a release once we are able to merge 1 more PR for iOS 15. Sorry for the mishap

babbage commented 2 years ago

@dostrander yes, that'd be it! My issue was indeed seen in UICollectionViews. Thanks for the update. :)