如果我们有多个 UITableView,我们如何在 XCUITest 中指定哪一个?
XCUIApplication().tables.cells.count
返回所有单元格。我们如何选择哪个表来限制计数?
最佳答案
使用辅助功能标识符来区分您的表格 View 。
class ViewController: UIViewController {
let firstTableView: UITableView!
let secondTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
firstTableView.accessibilityIdentifier = "First Table"
secondTableView.accessibilityIdentifier = "Second Table"
}
}
然后您可以在 UI 测试中直接引用其中一个表。
XCUIApplication().tables["First Table"].cells.count
关于ios - Xcode UI 测试 - 多个 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36487925/