2014-09-22 22 views
1

我寫了一個簡單的腳本,通過我的應用程序中的菜單。我可以訪問每個單元格,但我無法檢索其名稱。UIAutomation獲取TableView單元名稱

這是我的日誌樹: enter image description here

而這些都是方法:

function goThroughAllSideMenuCells() { 

    for (var index = 0; index < sideMenuCellsCount; index++) { 
     var cellName = getNameForCellAtIndex(index); 
     UIALogger.logMessage(cellName); 
     if (cellName == "Check-in") { 
      openCheckInCell(); 
     } else if (cellName == "Planta") { 
      openPlantaCell(); 
     } else { 
      openSideMenuItemWithIdentifier(cellName); 
     } 
    } 
} 

function getNameForCellAtIndex(index) { 

    return sideMenu.cells()[index].name(); 
} 
+0

嗨@vyudi你有這個實現代碼,你還沒有定義sideMenu或sideMenuCellsCount? – Jules 2015-04-21 08:09:07

回答

1

試試這個爲你獲取命名功能

function getNameForCellAtIndex(index) { 

    return sideMenu.cells()[index].staticTexts()[0].name(); 
} 

我注意到,因爲一個模式Xcode6改變了某些單元名稱,現在它們有時會分解爲多個staticText元素,因此如果您的單元格的名稱類似於(ite m1),(item2) 現在可能會顯示在兩個唯一的靜態文本項目中。所以你可能想要編輯這個函數來處理不僅僅是第一個靜態文本(這是我添加到你的函數中)。