UIAutomation获取视图

时间:2012-10-23 13:37:26

标签: ios ui-automation ios-ui-automation

我正在玩UIAutomation,我无法引用视图......

以下是视图可见的日志:main_view

UIAApplication: name:MyProjectDemo rect:{{0, 0}, {1024, 768}}
UIAWindow: rect:{{0, 0}, {1024, 768}}
UIAElement: name:main_view rect:{{0, 0}, {1024, 768}}

如何引用它并获取其子视图?

target = UIATarget.localTarget();
app = target.frontMostApp();
app.logElementTree();
mainWindow = app.mainWindow();

var view = mainWindow.views()["main_view"]; // doesn't work => undefined
var view = mainWindow.views()[0]; // doesn't work  => undefined

谢谢!

1 个答案:

答案 0 :(得分:2)

从元素树可见,它不是UIAView,因此您必须将其称为mainWindow.elements()["main_view"]