我一直在使用XCUITest来执行一些UI自动化。 我在页面上有一组单元格,并希望返回包含标签的单元格
设置断点并输入
po app.cells
返回
Output: {
Cell 0x6080003603c0: traits: 8589934592, {{162.9, 184.6}, {916.5, 83.6}}, label: 'reminder same title, description, 4.38 pm'
Cell 0x618000179380: traits: 8589934592, {{162.9, 268.2}, {916.5, 10.9}}
Cell 0x608000360300: traits: 8589934592, {{162.9, 279.1}, {916.5, 83.6}}, label: 'reminder same title, description different, 11.37 am'
Cell 0x618000179440: traits: 8589934592, {{162.9, 362.7}, {916.5, 10.9}}
Cell 0x600000363a80: traits: 8589934592, {{162.9, 373.6}, {916.5, 83.6}}, label: 'reminder same title, other description, 11.03 am'
Cell 0x608000360180: traits: 8589934592, {{162.9, 457.2}, {916.5, 10.9}}
Cell 0x618000179500: traits: 8589934592, {{162.9, 468.0}, {916.5, 83.6}}, label: 'name A, second, 11.00 am'
Cell 0x618000179740: traits: 8589934592, {{162.9, 551.7}, {916.5, 10.9}}
Cell 0x610000177580: traits: 8589934592, {{162.9, 562.5}, {916.5, 83.6}}, label: 'name A, first, 11.00 am'
Cell 0x600000363000: traits: 8589934592, {{162.9, 646.1}, {916.5, 10.9}}
Cell 0x618000179d40: traits: 8589934592, {{409.4, 362.2}, {293.2, 27.1}}
Cell 0x600000364800: traits: 8589934592, {{409.4, 389.3}, {293.2, 27.1}}
我理解更简单的方法是将可访问性标识符与具有标签的单元格相关联,但我不确定如何构造NSPredicate查询以探测Cells集合并仅返回包含标签的单元格。 / p>
答案 0 :(得分:0)
这应该为您提供标签不是
的所有单元格let predicate = NSPredicate(format: "label != nil")
let cells = XCUIApplication().cells.matching(predicate)