2016-04-28 66 views
1

我正在處理有很多元素的UICollectionView。其中之一,它是一個UISuplementaryView,其中包含許多可點擊的單元格(這是一個日曆)。有沒有辦法使用座標來選擇iOS UI Test Automation中的元素?

當我做po print(debugDescription)我得到類型「其他」,看起來像的許多元素此
Other 0x7f8a4cb06e30: traits: 8589934592, {{0.0, -1175.5}, {50.0, 38.0}}
有誰知道是否有使用這些座標與要素互動的方式?

回答

1

首先嚐試在下拉到座標API之前分配元素可訪問性特徵。在您的生產代碼中,在UISupplementaryView上設置accessibilityIdentifier

let app = XCUIApplication() 
app.otherElements["Reusable View 3"].tap() 

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { 
    UICollectionReusableView *reusableview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Identifier" forIndexPath:indexPath]; 
    reusableView.accessibilityIdentifier = "Reusable View \(indexPath.row)" 
    return reusableView 
} 

然後,在UI測試,它通過互動

相關問題