【发布时间】:2016-04-21 09:17:39
【问题描述】:
我正在用 XCode/Swift 为应用程序编写一些 UITest。在这个应用程序中,我有一个带有一些单元格的 UITableView(当然),但是对于测试,这个 tableview 的行为就像它是空的一样。
print(XCUIApplication().descendantsMatchingType(.Any).matchingIdentifier("HelpContainer").tables.descendantsMatchingType(.Any).debugDescription)
我已经添加了可访问性标识符,但正如您在此日志中看到的那样,它仍然是空的。
↪︎Find: Descendants matching type Any
Output: {
Image 0x7fd33c127630: traits: 8589934596, {{0.0, 64.0}, {375.0, 1.0}}
Image 0x7fd33ac37890: traits: 8589934596, {{0.0, 0.0}, {375.0, 64.0}}
Button 0x7fd33c40b780: traits: 8589934593, {{8.0, 26.0}, {54.0, 30.0}}, label: 'Cancel'
Button 0x7fd33c143b80: traits: 8724152321, {{8.0, 31.5}, {21.0, 21.0}}, label: 'Back'
StaticText 0x7fd33c1e67c0: traits: 8590000192, {{168.5, 29.0}, {38.5, 27.0}}, label: 'Help'
NavigationBar 0x7fd33ac0fd30: traits: 35192962023424, {{0.0, 20.0}, {375.0, 44.0}}, identifier: 'Help'
Other 0x7fd33ac39370: traits: 8589934592
Table 0x7fd33c144b00: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33c1e7570: traits: 8589934592
Other 0x7fd33ac38b40: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}, identifier: 'HelpContainer'
Other 0x7fd33ac383c0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33ac37c40: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33ac26240: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33ac25fb0: {{0.0, 0.0}, {375.0, 667.0}}
Window 0x7fd33ac2bdb0: Main Window, {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33ac39b30: traits: 8589934592
Other 0x7fd33c1e6f80: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
Window 0x7fd33c1e78c0: {{0.0, 0.0}, {375.0, 667.0}}
Other 0x7fd33ac3b1b0: {{0.0, 0.0}, {375.0, 20.0}}
Other 0x7fd33c1450a0: traits: 8388608, {{6.0, 0.0}, {54.0, 20.0}}
Other 0x7fd33c121790: traits: 8388608, {{65.0, 0.0}, {13.0, 20.0}}, label: '3 of 3 Wi-Fi bars', value: SSID
Other 0x7fd33ac3b4d0: traits: 8389120, {{163.0, 0.0}, {52.0, 20.0}}, label: '11:12 AM'
Other 0x7fd33ac3bc60: traits: 8388608, {{345.0, 0.0}, {25.0, 20.0}}, label: '-100 % battery power'
Other 0x7fd33ad671b0: {{0.0, 0.0}, {375.0, 20.0}}
StatusBar 0x7fd33ac3aa40: {{0.0, 0.0}, {375.0, 20.0}}
Window 0x7fd33ac3a2c0: {{0.0, 0.0}, {375.0, 667.0}}
}
↪︎Find: Elements matching predicate '"HelpContainer" IN identifiers'
Output: {
Other 0x7fd33ac38b40: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}, identifier: 'HelpContainer'
}
↪︎Find: Descendants matching type Table
Output: {
Table 0x7fd33c144b00: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
}
↪︎Find: Descendants matching type Any
“HelpContainer”是包含 UITableView 的视图的标识符,因为您可以看到表格视图本身在那里,但之后什么也没有。有谁知道应该怎么做才能解决这个问题?
提前谢谢:)
附言 我用了XCode辅助检查器,结果基本一样
【问题讨论】:
标签: ios xcode uitableview xcode-ui-testing uiaccessibility