Skip to content

Commit cf7ece5

Browse files
author
Justin Martin
committed
Fix bug with table view elements that are matched but offscreen
1 parent c45b50d commit cf7ece5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Classes/KIFUITestActor.m

+17
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,23 @@ - (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView
321321
KIFTestWaitCondition(view.isUserInteractionActuallyEnabled, error, @"View is not enabled for interaction: %@", view);
322322

323323
CGPoint tappablePointInElement = [self tappablePointInElement:element andView:view];
324+
325+
// If the element isn't immediately tappable, try checking if it is contained within scroll views that can be scrolled to make it tappable.
326+
if (isnan(tappablePointInElement.x)) {
327+
UIView *container = view;
328+
329+
do {
330+
if ([container isKindOfClass:UIScrollView.class]) {
331+
UIScrollView *containerScrollView = (UIScrollView *)container;
332+
CGRect rect = [view convertRect:view.frame toView:containerScrollView];
333+
[containerScrollView scrollRectToVisible:rect animated:NO];
334+
}
335+
336+
container = container.superview;
337+
} while (container != nil);
338+
339+
tappablePointInElement = [self tappablePointInElement:element andView:view];
340+
}
324341

325342
// This is mostly redundant of the test in _accessibilityElementWithLabel:
326343
KIFTestWaitCondition(!isnan(tappablePointInElement.x), error, @"View is not tappable: %@", view);

0 commit comments

Comments
 (0)