[英]How to access children of mainWindow for UI Automation in Xcode
I have a structure in the mainWindow() of my application as follows: 我的应用程序的mainWindow()中有一个结构,如下所示:
Within the children directory of the UIAWindow near the top of the image, I am trying to access Item 1, where it is a UIAButton. 在图像顶部附近的UIAWindow的子目录中,我试图访问项目1,即UIAButton。
This structure is generated from 这个结构是从
#import "tuneup/tuneup.js"
goAbout = function(target, app)
{
UIATarget.localTarget().frontMostApp().mainWindow().logElementTree();
};
test("go about", goAbout);
If I add .button()
or [1]
it raises an exception, so I cannot do something like so 如果我添加.button()
或[1]
会引发异常,所以我不能做这样的事情
...
UIATarget.localTarget().frontMostApp().mainWindow().buttons().logElementTree();
What can I do to access the object within the children subdirectory of the UIAWindow? 如何访问UIAWindow的children子目录内的对象?
That tree hierarchy ended up not meaning anything useful to me, and I ended up utilizing target methods to access the elements of my window. 树的层次结构最终对我没有任何意义,并且最终我使用目标方法访问了窗口的元素。 Cheers! 干杯!
You can access that button by adding .buttons()[0]
. 您可以通过添加.buttons()[0]
来访问该按钮。 The 的
UIATarget.localTarget().frontMostApp().mainWindow().buttons();
expression returns a javascript array (which has a 0 based indexing). expression返回一个javascript数组(具有从0开始的索引)。
Here you can find a rather usable documentation: https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/UIAutomationRef.pdf 在这里您可以找到一个相当有用的文档: https : //developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/UIAutomationRef.pdf
Anyway studying this plist is not the most convenient method to explore your object hierarchy. 无论如何,研究此plist并不是探索对象层次结构的最便捷方法。 I prefer to check instruments output directy. 我更喜欢直接检查仪器的输出。 (Or standard output, if you run instruments from command line.) (如果从命令行运行仪器,则为标准输出。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.