iphone中tabbar的自动化问题

时间:2012-12-05 06:09:08

标签: javascript ios6 instruments iphone-5 ios-ui-automation

我正在使用仪器工具上的自动化检查我的应用程序使用java脚本当我的应用程序有两个tabbars当我通过javascript代码点击第二个选项卡

var target = UIATarget.localTarget();

var app = target.frontMostApp();
var window = app.mainWindow();
var tabbar = window.tabBar().buttons()["Product"].tap();
UIALogger.logStart("Logging element tree …");
UIALogger.logPass();

它完美无缺。在产品选项卡中有一个UITableviewcontroller现在我写了javascript,点击tableview单元格如“`

tabar.tableviews()[0].cells()[0].tab;

不起作用。我该怎么处理这个问题。

1 个答案:

答案 0 :(得分:1)

我认为你不想从标签栏开始查找你的桌面视图,但我不完全确定我理解你的问题。我正在研究一些UIAutomation脚本,所以这里有几个片段 - 希望其中一个是相关的。

要点按UIToolBarController中的按钮,请使用:

var app = target.frontMostApp();
app.mainWindow().tabBar().buttons()["Saved"].tap(); // The name of the button is "Saved".

您也可以使用索引,例如[0]作为第一个标签栏按钮。在带有UITableView的屏幕上,我使用它来点击其中的单元格:

app.mainWindow().tableViews()[0].cells()["Name"].tap(); // The cell is named "Name".

同样,您也可以使用索引。请注意,我不是从标签栏开始,而是从app变量开始。

如果某些东西没有按照您认为应该的方式工作,请始终注销树并查看其中包含的内容。这总是对我有所帮助:

app.mainWindow().tableViews()[0].logElementTree();

Apple documentation就此有更多例子。