簡體   English   中英

UIAutomation獲取TableView單元格名稱

[英]UIAutomation get TableView cell name

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

這是我的日志樹: 在此處輸入圖片說明

這些是方法:

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項中顯示。 因此,您可能需要編輯函數以處理獲取的內容不僅僅是第一個靜態文本(這是我添加到函數中的內容)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM