2014-09-22 72 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) 现在可能会显示在两个唯一的静态文本项目中。所以你可能想要编辑这个函数来处理不仅仅是第一个静态文本(这是我添加到你的函数中)。