【发布时间】:2017-11-03 04:28:49
【问题描述】:
我是 UITests 的初学者。目前,我有一个问题,我无法访问 collectionViewCell 中的元素。
我的 UI 元素结构:
UIViewController
- UITableView
-- UITableViewCell
---> UICollectionView
----> UICollectionViewCell
-----> The element that I would like to get.
我试过下面的代码:
let tableCellContainer = app.tables["HomeRVMPTableView"].cells.element(boundBy: 0) // Get the first Cell of TableView
let collectionContainer = tableCellContainer.collectionViews["ContainerItemCollectionView"].cells.element(boundBy: 1) // Get the second Cell inside collectionView
let collectionElement = collectionContainer.staticTexts["BuyCashCard"]
XCTAssertFalse(!collectionElement.exists) // FAILED
有什么方法可以更轻松地访问 collectionViewCell/tableViewCell 吗?开始使用 UITests 时我很累。
【问题讨论】:
-
如果您正在检查
exists是否为 false 并且它失败了,那么看起来您 正在 获取单元格。所以基本上细胞确实存在...... -
@Oletha 很抱歉我的错误,我已经更新了上面的代码 (XCTAssertFalse(!collectionElement.exists))。在这种情况下它仍然不起作用
标签: ios uicollectionview xctest