我编写了以下脚本来点击用户界面上的按钮。每次按下都会增加 UILabel 的整数值。我希望读取脚本中 UILabel 的值。我怎样才能实现这个目标?我是仪器中这个自动化工具的新手。
var target = UIATarget.localTarget();
var appName = target.frontMostApp().mainWindow().name;
target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);
target.frontMostApp().mainWindow().buttons()["Increment"].tap();
最佳答案
首先确保您为该 UILabel 分配了辅助功能标识符。
您可以通过代码来做到这一点:
self.myLabel.accessibilityIdentifier = @"uniqueId";
或者通过 Storyboard:
要获取标签值,请在 UIAutomation 脚本中使用以下行:
target.frontMostApp().mainWindow().staticTexts()["uniqueId"].value();
关于ios - 读取 Xcode 中 Instruments 的 Automation 模板中 UILabel 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36549751/