这让我疯狂,如果有人能帮忙我会非常感激... 我正在尝试编写一个UI自动化脚本来测试一个应用程序。有一个特定的集合视图,在这个视图中,单元格是通过首先加载视图后从nib生成的...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"Forms";
[self.categoryCollectionView registerNib:[UINib nibWithNibName:@"HomeCategoryCell" bundle:nil] forCellWithReuseIdentifier:@"HomeCategoryCell"];
[self.formsCollectionView registerNib:[UINib nibWithNibName:@"HomeFormCell" bundle:nil] forCellWithReuseIdentifier:@"HomeFormCell"];
[self.existingFormsCollectionView registerNib:[UINib nibWithNibName:@"HomeExistingFormCell" bundle:nil] forCellWithReuseIdentifier:@"HomeExistingFormCell"];
[self setupFormCategories];
}
接着是设置表单方法...
- (void)setupFormCategories
{
categories = [[NSMutableArray alloc] init];
FormCategory *cat = [[FormCategory alloc] init];
cat.categoryTitle = @"All Forms";
cat.iconFileName = @"CategoryIcon.png";
cat.relatedForms = @[@"Form Type 1", @"Form Type 2"];
[categories addObject:cat];
cat = [[FormCategory alloc] init];
cat.categoryTitle = @"Customer Forms";
cat.iconFileName = @"CategoryIcon.png";
cat.relatedForms = @[@"Form Type 1", @"Form Type 2"];
[categories addObject:cat];
cat = [[FormCategory alloc] init];
cat.categoryTitle = @"Client Forms";
cat.iconFileName = @"CategoryIcon.png";
cat.relatedForms = @[@"Form Type 1", @"Form Type 2"];
[categories addObject:cat];
cat = [[FormCategory alloc] init];
cat.categoryTitle = @"User Forms";
cat.iconFileName = @"CategoryIcon.png";
cat.relatedForms = @[@"Form Type 1", @"Form Type 2"];
[categories addObject:cat];
brandNewForms = nil;
}
我尝试了几种选择这些表单的方法,(包括类别标题和相关表单...
target.frontMostApp().mainWindow().collectionViews()[0].cells()["User Forms"].tap();
除了firstWithPredicate等方法之外......但我总是得到相同的响应....
脚本抛出了未捕获的JavaScript错误:目标.frontMostApp()。mainWindow()。collectionViews()[0]。cells()[“用户表单”]无法点击,因为该元素在线64 wip.js上不可见。
如果我记录元素树,则可以看到所有元素类型并返回完整的元素树。 如果我通过Instruments记录用户交互,则会识别元素,并生成此javascript...
target.frontMostApp().mainWindow().collectionViews()[0].cells()["User Forms"].tap();
无论我做什么都无法让它工作。我尝试通过界面构建器更改辅助功能设置,确保它所属的视图没有任何辅助功能设置,但是我无法让它工作。我也不明白为什么在logElementTree和record中能够识别元素,但是在运行时却不能识别......有什么想法吗?如果这是问题,有什么修改Objective-C代码的建议吗?我尝试使用cat.accessibilityLabel =“User Forms”进行测试,但我是Objective-C的新手,不知道自己在做什么.....xCode 5 / iOS7模拟器...但我也尝试过在xCode 4.6.3 / iOS6.1上...