2016-04-28 69 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测试,它通过互动

相关问题