我有一个非常简单的应用程序,其中包括一个TableViewController,它显示一个包含图像,标签和按钮的自定义单元格的表格,当您点击按钮时,将显示actionSheet.所以,在我的自定义java脚本中(使用Instruments-UIAutomation)我想在我的表中按下按钮(我可以毫无问题地执行此操作),然后当actionSheet出现时我只想点击唯一的按钮(取消按钮)它表明.
我不知道如何正确地做到这一点.所以这是我的js代码:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var main = app.mainWindow();
main.tableViews()[0].cells()[1].buttons()["DetailsButton"].tap();
target.delay(5);
main.actionSheet().elements()[0].tap();
Run Code Online (Sandbox Code Playgroud)
这就是我得到的信息:
Script threw an uncaught JavaScript error: 'undefined' is not a function (evaluating 'main.actionSheet()') on line 9 of New%20Script
Run Code Online (Sandbox Code Playgroud)
我也试过actionSheet().buttons()[0].tap();
- 没有帮助,继续得到同样的错误.
我甚至尝试通过它的accessibleLabel访问actionSheet:
main.actionSheet()["CellNumberSheet"].elements()[0].tap();
Run Code Online (Sandbox Code Playgroud)
如果它会有所帮助,那就是我显示我的actionSheet的方式:
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
Run Code Online (Sandbox Code Playgroud)
元素层次结构似乎也是正确的.
没有在网上找到太多有用的信息...所以任何帮助将不胜感激...
javascript uiactionsheet ios xcode-instruments ios-ui-automation