@@ -323,6 +323,13 @@ - (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView
323
323
KIFTestWaitCondition (view.isUserInteractionActuallyEnabled , error, @" View is not enabled for interaction: %@ " , view);
324
324
325
325
CGPoint tappablePointInElement = [self tappablePointInElement: element andView: view];
326
+
327
+ // If the element isn't immediately tappable, try checking if it is contained within scroll views that can be scrolled to make it tappable.
328
+ if (isnan (tappablePointInElement.x )) {
329
+ [self _scrollViewToTappablePointIfNeeded: view];
330
+
331
+ tappablePointInElement = [self tappablePointInElement: element andView: view];
332
+ }
326
333
327
334
// This is mostly redundant of the test in _accessibilityElementWithLabel:
328
335
KIFTestWaitCondition (!isnan (tappablePointInElement.x ), error, @" View is not tappable: %@ " , view);
@@ -406,6 +413,12 @@ - (void)longPressAccessibilityElement:(UIAccessibilityElement *)element inView:(
406
413
KIFTestWaitCondition (view.isUserInteractionActuallyEnabled , error, @" View is not enabled for interaction: %@ " , view);
407
414
408
415
CGPoint tappablePointInElement = [self tappablePointInElement: element andView: view];
416
+ // If the element isn't immediately tappable, try checking if it is contained within scroll views that can be scrolled to make it tappable.
417
+ if (isnan (tappablePointInElement.x )) {
418
+ [self _scrollViewToTappablePointIfNeeded: view];
419
+
420
+ tappablePointInElement = [self tappablePointInElement: element andView: view];
421
+ }
409
422
410
423
// This is mostly redundant of the test in _accessibilityElementWithLabel:
411
424
KIFTestWaitCondition (!isnan (tappablePointInElement.x ), error, @" View is not tappable: %@ " , view);
@@ -1570,6 +1583,13 @@ - (void)tapStepperWithAccessibilityElement:(UIAccessibilityElement *)element inc
1570
1583
KIFTestWaitCondition (view.isUserInteractionActuallyEnabled , error, @" View is not enabled for interaction: %@ " , view);
1571
1584
1572
1585
CGPoint stepperPointToTap = [self tappablePointInElement: element andView: view];
1586
+
1587
+ // If the element isn't immediately tappable, try checking if it is contained within scroll views that can be scrolled to make it tappable.
1588
+ if (isnan (stepperPointToTap.x )) {
1589
+ [self _scrollViewToTappablePointIfNeeded: view];
1590
+
1591
+ stepperPointToTap = [self tappablePointInElement: element andView: view];
1592
+ }
1573
1593
1574
1594
switch (stepperDirection)
1575
1595
{
@@ -1580,6 +1600,7 @@ - (void)tapStepperWithAccessibilityElement:(UIAccessibilityElement *)element inc
1580
1600
stepperPointToTap.x -= CGRectGetWidth (view.frame ) / 4 ;
1581
1601
break ;
1582
1602
}
1603
+
1583
1604
1584
1605
// This is mostly redundant of the test in _accessibilityElementWithLabel:
1585
1606
KIFTestWaitCondition (!isnan (stepperPointToTap.x ), error, @" View is not tappable: %@ " , view);
@@ -1632,6 +1653,21 @@ - (KIFDisplacement)_displacementForSwipingInDirection:(KIFSwipeDirection)directi
1632
1653
}
1633
1654
}
1634
1655
1656
+ - (void )_scrollViewToTappablePointIfNeeded : (UIView *)view
1657
+ {
1658
+ UIView *container = view;
1659
+
1660
+ do {
1661
+ if ([container isKindOfClass: UIScrollView.class]) {
1662
+ UIScrollView *containerScrollView = (UIScrollView *)container;
1663
+ CGRect rect = [view convertRect: view.frame toView: containerScrollView];
1664
+ [containerScrollView scrollRectToVisible: rect animated: NO ];
1665
+ }
1666
+
1667
+ container = container.superview ;
1668
+ } while (container != nil );
1669
+ }
1670
+
1635
1671
+ (BOOL )testActorAnimationsEnabled ;
1636
1672
{
1637
1673
return KIFUITestActorAnimationsEnabled;
0 commit comments