javascript - iPhone - UI 自动化 - 使用 UIAKeyboard 键入

标签 javascript iphone ios-ui-automation

我使用 UIAutomation 来测试我的 iPhone 应用程序。
我的应用程序有一个 UISearchBar,在我将其聚焦后,
这行脚本显示应用程序现在有 2 个 UIAWindow

UIATarget.localTarget().frontMostApp().logElementTree();

第二个 UIAWindowUIAKeyboard 作为子项。

enter image description here

您知道如何获取第二个 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("这是一条消息");
作品

最佳答案

您发布的最后两个代码片段应该可以工作,但它们仅在键盘打开(在屏幕上可见)时才有效。另一种方法是访问文本字段(您想在其中输入您要输入的内容),然后调用函数 .setValue("Hello world").typeString (“ Hello World ”)。这两个是textField对象的函数。希望这会有所帮助。

关于javascript - iPhone - UI 自动化 - 使用 UIAKeyboard 键入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10638782/

相关文章:

javascript - 如何在一段时间后或多次操作后停止 setInterval?

javascript - 闪存组织结构图

iphone - iPhone:将NSString(unicode字符串)转换为char数组并反转

ios - 如何在运行时使用自动布局隐藏 ios 中的 View 以使 ui 保持一致?

ios - 在仪器中找不到 UI 记录器模板

javascript - CKeditor insertHtml/insertElement IE8问题

javascript - 使用 jQuery 更新文本框

iphone - 如何在iPhone中点击外部时隐藏下拉列表

iphone - UITableView 字体

ios - 如何在使用 Core Graphics 绘制的图像上设置辅助功能标签?