I was able to fix the scrolling issues I was having by modifying
_accessibilityElementWithLabel by changing the [scrollView
scrollRectToVisible:] to [scrollView setContentOffset:]. It appears
that there are also issues with trying to tap on a label in an
alertbox generated by jquery on the web page I was on. Removing the
check for tappability fixed this. Here is the modified source:
+ (UIAccessibilityElement *)_accessibilityElementWithLabel:(NSString
*)label accessibilityValue:(NSString *)value tappable:
(BOOL)mustBeTappable traits:(UIAccessibilityTraits)traits error:(out
NSError **)error;
{
UIAccessibilityElement *element = [[UIApplication
sharedApplication] accessibilityElementWithLabel:label
accessibilityValue:value traits:traits];
if (!element) {
if (error) {
// For purposes of a better error message, see if we can
find the view, just not a view with the specified value
if (value && [[UIApplication sharedApplication]
accessibilityElementWithLabel:label accessibilityValue:nil
traits:traits]) {
*error = [[[NSError alloc] initWithDomain:@"KIFTest"
code:KIFTestStepResultFailure userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Found an
accessibility element with the label \"%@\", but not with the value
\"%@\"", label, value], NSLocalizedDescriptionKey, nil]] autorelease];
// Check the traits too
} else if (traits != UIAccessibilityTraitNone &&
[[UIApplication sharedApplication] accessibilityElementWithLabel:label
accessibilityValue:nil traits:UIAccessibilityTraitNone]) {
*error = [[[NSError alloc] initWithDomain:@"KIFTest"
code:KIFTestStepResultFailure userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Found an
accessibility element with the label \"%@\", but not with the traits
\"%d\"", label, traits], NSLocalizedDescriptionKey, nil]]
autorelease];
} else {
*error = [[[NSError alloc] initWithDomain:@"KIFTest"
code:KIFTestStepResultFailure userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Failed to
find accessibility element with the label \"%@\"", label],
NSLocalizedDescriptionKey, nil]] autorelease];
}
}
return nil;
}
// Make sure the element is visible
UIView *view = [UIAccessibilityElement
viewContainingAccessibilityElement:element];
if (!view) {
if (error) {
*error = [[[NSError alloc] initWithDomain:@"KIFTest"
code:KIFTestStepResultFailure userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:[NSString stringWithFormat: @"Cannot find
view containing accessibility element with the label \"%@\"", label],
NSLocalizedDescriptionKey, nil]] autorelease];
}
return nil;
}
// Scroll the view to be visible if necessary
UIScrollView *scrollView = (UIScrollView *)view;
while (scrollView && ![scrollView isKindOfClass:[UIScrollView
class]]) {
scrollView = (UIScrollView *)scrollView.superview;
}
if (scrollView) {
if ((UIAccessibilityElement *)view == element) {
[scrollView scrollViewToVisible:view animated:YES];
} else {
CGRect elementFrame = [view.window
convertRect:element.accessibilityFrame toView:scrollView];
[scrollView setContentOffset:CGPointMake(0,
elementFrame.origin.y - elementFrame.size.height) animated:YES];
}
// Give the scroll view a small amount of time to perform the
scroll.
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.3, false);
}
if ([[UIApplication sharedApplication]
isIgnoringInteractionEvents]) {
if (error) {
*error = [[[NSError alloc] initWithDomain:@"KIFTest"
code:KIFTestStepResultFailure userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:@"Application is ignoring interaction
events", NSLocalizedDescriptionKey, nil]] autorelease];
}
return nil;
}
return element;
}