我无法让 UI 测试记录自定义 UICollectionViewCell 选择。
怎么做?是否支持?
下面是我点击第一个单元格时自动生成的代码。
我也在设置这些属性:
在 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;
在我的 TestFile.m
XCUIApplication *app = [[XCUIApplication alloc] init];
[app.buttons[@"btnTabHistory"] tap];
[[[[[app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element tap];
如果您需要更多信息,请告诉我。:)