我编写了一个简单的脚本,它通过我的应用程序中的菜单。我可以访问每个单元格,但无法检索它们的名称。
这是我的日志树:
这些是方法:
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();
}
最佳答案
试试这个获取名字的功能
function getNameForCellAtIndex(index) {
return sideMenu.cells()[index].staticTexts()[0].name();
}
我注意到自 Xcode6 以来的一种模式,它改变了一些带有单元格名称的东西,现在它们有时会分解成多个 staticText 元素,所以如果你的单元格有一个像 (item1), (item2) 这样的名字 这现在可能会出现在两个独特的 staticText 项目中。因此,您可能想要编辑该函数以处理获取的不仅仅是第一个静态文本(这是我添加到您的函数中的内容)。
关于javascript - UIAutomation 获取 TableView 单元格名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25978901/