【发布时间】:2016-05-03 06:21:49
【问题描述】:
尝试使用 Xcode 7.2 和 XCT UI FW 自动化一些 UI 测试。
视图层次如下:
SearchViewController
UIView
UITableView
CustomCell:UITableViewCell
UIView
UILabel
UICollectionView
CustomCell:UICollectionViewCell
UILabel
UIImageView
CustomCell:UITableViewCell
.
.
我的问题是我无法访问 UICollectionView 中的任何内容,也无法实际访问 UICollectionView 本身(或验证它是否存在)。
这里有一些 lldb cmds 和输出:
po app.tables.cells.count 3
正如我所料,自我三个CustomCell:UITableViewCell
po app.tables.cells.elementBoundByIndex(0).staticTexts.count 1
为第一个 CustomCell:UITableViewCell 中的 UILabel 返回 1。但是由于 .elementType 表示法是 descendantsMatchingType(.elementType) 的缩写,因此它是否还应该在树的更下方,在 UICollectionViewCells 内包含 UILabel?
po app.tables.collectionViews.count 0
po app.tables.cells.collectionViews.element.exists false
如您所见,我无法访问 UICollectionView。在构建和测试应用程序时,每个 UITableViewCell 中有 8 个 UICollectionViewCells,我已在 Xcode 中将 Accessibility 复选框设置为启用。
我在这里错过了什么?
【问题讨论】:
-
什么给了你“app.collectionViews.count”?
-
@Che app.collectionViews.count 给我 0。
标签: xcode7 xctest xcode-ui-testing