在 Xcode UIAutomation 和 Instruments 中使用 Javascript 验证按钮对象是否存在
为了在 iOS 4.2 上对我们的项目进行质量测试,我们正在通过 Xcode 3.x 中的 Instruments 使用 UIAutomation。我们正在用 Javascript 编写脚本。我是 Javascript 的新手,并且发现 UIAutomation 文档是(我该怎么说?)“稀疏”。
我希望以太坊中的一些天才能够启发我,当我们的iOS应用程序的主窗口上显示一个名为“beep sound”的按钮时,如何验证它是否存在?
还有人找到了用 JavaScript 编写测试脚本(而不是动态网页)的好参考吗?
感谢您的任何和所有帮助!
问候,
史蒂夫·奥沙利文
For the quality testing of our project on iOS 4.2, we are working with UIAutomation though Instruments in Xcode 3.x. We are writing our scripts in Javascript. I am new to Javascript, and have found the UIAutomation documentation to be (how shall I put this?), "sparse".
I am hoping that some genius in the Ether may be able to enlighten me as to how to verify the existence of a button named 'beep sound' when it is displayed on the main window of our iOS application?
Also has anyone out there found any good references for writing test scripts (as opposed to dynamic web pages) in JavaScript?
Thanks for any and all assistance!
Regards,
Steve O'Sullivan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿。
实际上文档(this 和 这个)来自苹果是我唯一的东西可以找到。
至于你的问题尝试
当然,假设(elements()[0])你的按钮位于主窗口下的对象树中的第一个。如果不是,您可能需要调用其他元素 ((elements()3),或者您可能需要更深入地调用层次结构(elements()[0].elements()3)。
请记住,如果链中的对象之一不存在,上面的代码将会失败。您可能需要检查链中的每个对象。此外,您可能需要检查给定的按钮是否不仅存在,而且在屏幕上是否可见。在这种情况下,上面的代码可能需要如下所示:
但现在代码的可读性、可维护性和过度属性受到了影响。所以我将其重构为:
当然你仍然可以改进它......但你应该明白这个想法。
顺便说一句 Apple 谓词指南
PS代码是用记事本编写的,未经过检查,因此可能包含一些解析错误。
Hey.
Actually documentation (this and this) from apple is the only thing I could find.
As for your question try
Of course, that assumes (elements()[0]) that your button is first in object tree under main window. If it is not, you may need to call other element ((elements()3), or you may need to call deeper into hierarchy (elements()[0].elements()3).
Keep in mind that code above will fail if one of the objects in chain won't be present. You may need to check every object in chain. Additionally you may need to check if given button is not only present but if it visible on the screen. In this case code above may need to look like this:
But now readability, maintainability, and over -ity attributes of code suffer. So I would refactor it to:
Of course you can still improve it... but you should get the idea.
btw apple guide to predicates
P.S. Code was written in notepad, and wasn't checked so it may contain some parse errors.