我正在尝试创建一个XCUITest,其中我希望验证iOS的状态栏是否为:
但我找不到它..。例如:
func testExample() throws {
let app = XCUIApplication()
app.launch()
let statusBar1 = app.descendants(matching: .statusBar)
let statusBar2 = app.statusBars.element(boundBy: 0)
}当po statusBar1在控制台中运行时,我得到一个空的结果:
Find: Target Application 'com.domain.TestStatusBar'
↪︎Find: Descendants matching type StatusBar有怎么找到的线索吗?
谢谢!
发布于 2021-09-21 19:05:51
现在它可以作为跳板后裔使用了:
class Springboard {
static let shared = XCUIApplication(bundleIdentifier: "com.apple.springboard")
static var statusBar: XCUIElement {
// There are always two statusBars,
// but only one of them is accessible when we need to tap it
if XCUIDevice.shared.orientation.isPortrait {
return Springboard.shared.statusBars.firstMatch
}
else {
return Springboard.shared.statusBars.element(boundBy: 1)
}
}
}https://stackoverflow.com/questions/68934703
复制相似问题