【发布时间】:2013-12-10 01:34:49
【问题描述】:
我使用 UIAutomation 来测试我的 iPhone 应用程序。
我的应用程序有一个UISearchBar,在我让它集中之后,
这行脚本显示应用现在有 2 个UIAWindow。
UIATarget.localTarget().frontMostApp().logElementTree();
第二个UIAWindow 有UIAKeyboard 作为一个孩子。
你知道如何获取第二个UIAWindow 的引用,以便我可以获取UIAKeyboard 的引用吗?
我试过了
UIATarget.localTarget().frontMostApp().mainwindow()[1].keyboard().key()["Q"].tap();
但它不起作用。
编辑 1:
我使用这条线来获取键盘的参考。有用。
UIATarget.localTarget().frontMostApp().windows()[1].logElementTree();
但是当我尝试用键盘输入内容时:
UIATarget.localTarget().frontMostApp().keyboard().typeString("Hello world");
或
UIATarget.localTarget().frontMostApp().keyboard().keys()["A"].tap;
但它们不起作用。
你知道如何用键盘输入东西吗?
编辑: (只是为了让你们知道如何让 UIAKeyboard 为您工作)
UIATarget.localTarget().frontMostApp().keyboard().keys()["A"].tap;
不起作用
UIATarget.localTarget().frontMostApp().keyboard().keys()["A"].tap();
有效
和
UIATarget.localTarget().frontMostApp().keyboard().typeString("This is a message");
有效
【问题讨论】:
标签: javascript iphone ios-ui-automation