2012-12-05 48 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