2012-12-05 45 views
1

我使用仪器的自动化工具检查使用Java脚本我的应用程序时,我应用程式有两个tabbars当我下面的代码自动化问题

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(); 

其工作完全通过JavaScript点击第二个选项卡。在产品标签有一个的UITableViewController现在我写的JavaScript单击像as`

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

不工作的实现代码如下细胞。我该如何处理这个问题。

回答

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.mainWindow().tableViews()[0].logElementTree(); 

Apple documentation在这个拥有更多的例子。

+0

感谢您的答复。我已经得到了答案。任何方式我会给你的答案是正确的 – Ben10