仪器仪表自动化:遍历所有按钮 [英] Instruments automation: iterate for all buttons

查看:417
本文介绍了仪器仪表自动化:遍历所有按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的自动化应用程序之一的过程。

I'm in the process of automate one of my apps.

首先,我轻按一个的TabBar =>确定

First I tap on a tabBar =>ok

点击=>确定

填写我的我的tableView =>确定

Fill some data of my textFields of my tableView => ok

塔上的一些细胞,然后打开一个新的ViewController =>确定

Tap on some cell and open a new ViewController => ok

在这个新的控制器=>没有在添加按钮,点击会发生...

Tap on a 'Add' button in this new controller => nothing happens ...

按钮相同的第一个观点:UIBarButtonSystemItemAdd

The button is the same as the first view: UIBarButtonSystemItemAdd

所以,现在我想告诉所有的自动化可以找到的按钮,进行迭代,并得到他们的名字,只是为了检查所有的都很顺利,但我找不到按钮的名称,请参见:

So, now I want to show all the buttons that automation can find, and iterate and get their names, just to check that all is going well, but I can't find the name of the buttons, see:

var arr = UIATarget.localTarget().frontMostApp().navigationBar().buttons();
for(var i=0; i<arr.length; i++) {
  var value = arr[i];
  UIALogger.logMessage(value.name);
}

和我敲击按键都以同样的方式:

And I'm tapping both buttons the same way:

UIATarget.localTarget().frontMostApp() .navigationBar().buttons()["Add"].tap();

感谢,

好吧,按钮水龙头已使用1的延迟解决

Ok, the button tap has been solved using a delay of 1

但我不能在循环按钮的名称,但至少我可以继续我的auomating应用

But I can't get the button names in the loop, but at least I can continue auomating my app

推荐答案

要看到你的屏幕上有在某一个时刻什么样的元素,把

To see what elements your screen has at a certain moment, put

UIATarget.localTarget().logElementTree();

在你的脚本。它会显示在你的应用程序的当前状态与他们的辅助功能属性的所有元素(名称和值)。

in your script. It will show all elements with their accessibility properties (name and value) in your app's current state.

如果你的按钮还没有名字,你必须在你的X code项目设置可访问性属性这些按键,请参阅的。

If your buttons has not names, you have to set accessibility properties in your XCode project for these buttons, see there.

这篇关于仪器仪表自动化:遍历所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆