0

I am not able to get UI Testing record a custom UICollectionViewCell selection.

How to do it? Is it supported?

Below is the code automatically generated when i tapped first cell.

I am setting these properties too:

in cellForItemAtIndexPath

cell.isAccessibilityElement = YES;
cell.accessibilityIdentifier = [NSString stringWithFormat:
                                @"HistoryCollectionViewCell-%d-%d",
                                (int)indexPath.section,
                                (int)indexPath.item];
cell.accessibilityValue = cell.accessibilityIdentifier;
cell.accessibilityLabel = cell.accessibilityIdentifier;


cell.contentView.isAccessibilityElement = YES;
cell.contentView.accessibilityIdentifier = [NSString stringWithFormat:
                                            @"HistoryObjectContentView-%d-%d",
                                            (int)indexPath.section,
                                            (int)indexPath.item];
cell.contentView.accessibilityValue = cell.contentView.accessibilityIdentifier;
cell.contentView.accessibilityLabel = cell.contentView.accessibilityIdentifier;

In my TestFile.m

XCUIApplication *app = [[XCUIApplication alloc] init];

[app.buttons[@"btnTabHistory"] tap];

[[[[[app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element tap];

Let me know if you need more info. :)

Akshit Zaveri
  • 4,166
  • 6
  • 30
  • 59

1 Answers1

4

Found it. Turns out, i had set accessibility enabled for all the parent views. I disabled all accessibility for those views, and it worked. Accessibility inspector helped me a lot.

If anyone is facing similar issues, you can open the accessibility inspector by right click on XCode (from dock) -> Open Developer Tool -> Accessibility Inspector

Akshit Zaveri
  • 4,166
  • 6
  • 30
  • 59