我想在下面的代码中找到两个XCUIElements并且没有问题。
func cells(_ text:String) {
app.cells.element(withLabelContaining: text).firstMatch
}
func text(_ text:String) {
app.staticText.element(withLabelContaining: text).firstMatch
}但是,我想找到一种只使用一个查询来查找多个类型的XCUIElement的方法,我怎么做呢?我检查了文档,但找不到任何解决方案
不同类型的XCUIElement
发布于 2022-12-04 15:35:51
假设:
let app = XCUIApplication()app.staticText实际上是一种快捷方式
app.windows.descendants(matching: XCUIElement.ElementType.staticText)因此,通过类比,我们可以这样做:
let typesToBeFound = [XCUIElement.ElementType.cell.rawValue,
XCUIElement.ElementType.staticText.rawValue]
let predicateFormat = "elementType == %lu OR elementType == %lu"
let predicate = NSPredicate(format: predicateFormat, argumentArray: typesToBeFound)
let result = app.windows.descendants(matching: XCUIElement.ElementType.any).matching(predicate)https://stackoverflow.com/questions/74667454
复制相似问题