iOS UIAutomation:访问自动化脚本中 UIScrollView 上添加的自定义子视图
我对 iOS UIAutomation 非常陌生,这是我面临的问题
我有一个如下所示的视图层次结构,并且想要访问自动化 sctipt
UIWindow > 中的 CustomView2 元素UIScrollView > CustomView1(多个)> CustomView2(多个)
滚动视图具有 CustomView1 类型的子视图,而 CustomView1 又具有 CustomView2 类型的子视图。
我已将可访问性信息分配给层次结构中的所有视图,但无法访问自动化脚本中的 CustomView2 元素。
当我在 UIScrollView 上执行 logElementTree() 时,我得到的只是 CustomView2 的实例,CustomView2 甚至不在 UIWindow 的树结构中。
如果有什么遗漏或有什么问题,请提出建议。
这是我正在使用的代码
var mainWindow = application.mainWindow();
var scrollView = mainWindow.scrollViews()[0];
var custom1 = scrollView.elements().withName("CustomView1");
for(var index=0; index<custom1.length; index++){
currentIndustry.tap();
custom1[index].logElementTree();
var custom2 = custom1[index].elements().withName("CustomView2");
UIALogger.logPass("Custom2 Length : " + custom2.length);
}
打印的树 custom1[index].logElementTree(); 不包含 CustomView2 的
实例我需要访问 CustomView1 和 CustomView2 元素
I am very new to the iOS UIAutomation, here is the problem I am facing
I have a view hierarchy as below and want to access CustomView2 elements in the automation sctipt
UIWindow > UIScrollView > CustomView1 (Multiple) > CustomView2 (Multiple)
The scrollview has subviews of type CustomView1 and CustomView1 in turn has subviews of type CustomView2.
I have assigned the accessibility information to all of the views in hierarchy, but I am not able to access the CustomView2 elements in my automation script.
When I do a logElementTree() on UIScrollView, all I get is the instances of CustomView2, CustomView2 is not even in the tree structure of UIWindow.
Please suggest if is there anything missing or anything going wrong.
Here is the code I am using
var mainWindow = application.mainWindow();
var scrollView = mainWindow.scrollViews()[0];
var custom1 = scrollView.elements().withName("CustomView1");
for(var index=0; index<custom1.length; index++){
currentIndustry.tap();
custom1[index].logElementTree();
var custom2 = custom1[index].elements().withName("CustomView2");
UIALogger.logPass("Custom2 Length : " + custom2.length);
}
The tree printed by
custom1[index].logElementTree();
does not contain instances of CustomView2
P.S. I need to access both CustomView1 and CustomView2 elements
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您还没有找到答案,这可能会对您有所帮助:
UIAutomation Nested Accessibilty Elements从层次结构中消失
在您的 CustomView1 类中实现以下内容:
这将使您的 CustomView2 元素在您 logElementTree() 时可见。
如果 CustomView2 包含可访问元素并且基本上也是一个容器视图,那么也在该类中实现上述内容,并且它的子视图将变得可访问。
This may help you if you haven't found your answer already:
UIAutomation Nested Accessibilty Elements Disappear from Hierarchy
In your CustomView1 class implement the following:
This will make your CustomView2 elements visible when you logElementTree().
If CustomView2 contains accessible elements and is basically a container view as well, then implement the above in that class as well, and it's child views will become accessible.