gpt4 book ai didi

ios - UI 自动化 "could not be tapped because the element is not visible"iOS

转载 作者:可可西里 更新时间:2023-11-01 06:15:38 25 4
gpt4 key购买 nike

这让我发疯,如果有人能提供帮助,我将不胜感激......我正在尝试编写一个 ui 自动化脚本来测试应用程序。有一个特定的 Collection View ,其中单元格是通过首先加载 View 从 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 错误:target.frontMostApp().mainWindow().collectionViews()[0].cells()["User Forms"] 无法点击,因为该元素在第 64 行不可见wip.js

如果我记录元素树,它可以看到所有元素类型并返回完整的元素树。如果我通过 Instruments 记录用户交互,它会识别元素,并生成此 javascript...

target.frontMostApp().mainWindow().collectionViews()[0].cells()["User Forms"].tap();

无论我做什么我都无法让它工作。我已经尝试通过界面生成器更改可访问性设置,确保它是 subview 的 View 没有任何可访问性设置,但是我无法让它工作。我也不明白为什么它会识别 logElementTree 中的元素并记录,但运行时却不能...

任何想法......如果这是问题,我可以如何修改 objective-c 代码的任何建议......?我试过玩 cat.accessibilityLabel= @"User Forms";但我是 objective-c 的新手,我真的不知道自己在做什么....

xCode 5/iOS7 模拟器...但我也在 xCode 4.6.3/iOS6.1 中尝试过...

最佳答案

从您对问题的描述来看,听起来您要点击的单元格在 View 层次结构中,但实际上只是在屏幕上不可见。

也许您必须先滚动才能使其可见。此外,看起来您有不同类别的元素。在该单元格可见之前,您可能必须在应用中选择正确的类别。

关于ios - UI 自动化 "could not be tapped because the element is not visible"iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18898484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com