diff --git a/Additions/UIAccessibilityElement-KIFAdditions.m b/Additions/UIAccessibilityElement-KIFAdditions.m index 609516a70..ebb0aba13 100644 --- a/Additions/UIAccessibilityElement-KIFAdditions.m +++ b/Additions/UIAccessibilityElement-KIFAdditions.m @@ -18,6 +18,11 @@ MAKE_CATEGORIES_LOADABLE(UIAccessibilityElement_KIFAdditions) +@interface UIAccessibilityElement (KIFAdditions_Private) + +- (id)tableViewCell; // UITableViewCellAccessibilityElement + +@end @implementation UIAccessibilityElement (KIFAdditions) @@ -26,7 +31,9 @@ + (UIView *)viewContainingAccessibilityElement:(UIAccessibilityElement *)element while (element && ![element isKindOfClass:[UIView class]]) { // Sometimes accessibilityContainer will return a view that's too far up the view hierarchy // UIAccessibilityElement instances will sometimes respond to view, so try to use that and then fall back to accessibilityContainer - id view = [element respondsToSelector:@selector(view)] ? [(id)element view] : nil; + id view = [element respondsToSelector:@selector(view)] ? [(id)element view] + : [element respondsToSelector:@selector(tableViewCell)] ? [(id)element tableViewCell] + : nil; if (view) { element = view; diff --git a/KIF Tests/TableViewTests.m b/KIF Tests/TableViewTests.m index 0f94fc2dd..cb6403211 100644 --- a/KIF Tests/TableViewTests.m +++ b/KIF Tests/TableViewTests.m @@ -83,6 +83,20 @@ - (void)testTappingRowUnderToolbarByLabel [tester tapViewWithAccessibilityLabel:@"Cell 32"]; } +- (void)testWaitingRowByLabel +{ + UIView *v = [tester waitForViewWithAccessibilityLabel:@"First Cell"]; + XCTAssertTrue([v isKindOfClass:[UITableViewCell class]] || [v isKindOfClass:NSClassFromString(@"UITableViewLabel")], @"actual: %@", [v class]); +} + +- (void)testWaitingRowByLabelAfterTapping +{ + // for view lookup changes caused by tapping rows + [tester tapViewWithAccessibilityLabel:@"First Cell"]; + UIView *v = [tester waitForViewWithAccessibilityLabel:@"First Cell"]; + XCTAssertTrue([v isKindOfClass:[UITableViewCell class]] || [v isKindOfClass:NSClassFromString(@"UITableViewLabel")], @"actual: %@", [v class]); +} + - (void)testMoveRowDown { [tester tapViewWithAccessibilityLabel:@"Edit"]; diff --git a/KIF Tests/TableViewTests_ViewTestActor.m b/KIF Tests/TableViewTests_ViewTestActor.m index edfa2df82..91565bed1 100644 --- a/KIF Tests/TableViewTests_ViewTestActor.m +++ b/KIF Tests/TableViewTests_ViewTestActor.m @@ -83,6 +83,20 @@ - (void)testTappingRowUnderToolbarByLabel [[viewTester usingLabel:@"Cell 32"] tap]; } +- (void)testWaitingRowByLabel +{ + UIView *v = [[viewTester usingLabel:@"First Cell"] waitForView]; + XCTAssertTrue([v isKindOfClass:[UITableViewCell class]] || [v isKindOfClass:NSClassFromString(@"UITableViewLabel")], @"actual: %@", [v class]); +} + +- (void)testWaitingRowByLabelAfterTapping +{ + // for view lookup changes caused by tapping rows + [[viewTester usingLabel:@"First Cell"] tap]; + UIView *v = [[viewTester usingLabel:@"First Cell"] waitForView]; + XCTAssertTrue([v isKindOfClass:[UITableViewCell class]] || [v isKindOfClass:NSClassFromString(@"UITableViewLabel")], @"actual: %@", [v class]); +} + - (void)testMoveRowDown { [[viewTester usingLabel:@"Edit"] tap];