diff --git a/Samples/Shared/Common/Testing/Screen+Extensions.swift b/Samples/Shared/Common/Testing/Screen+Extensions.swift index ca4965c56..9c202d73e 100644 --- a/Samples/Shared/Common/Testing/Screen+Extensions.swift +++ b/Samples/Shared/Common/Testing/Screen+Extensions.swift @@ -88,8 +88,16 @@ extension WebLogin where Self: Screen { } } + func wait(for staticText: String, timeout: TimeInterval = .standard) -> Bool { + guard app.staticTexts[staticText].waitForExistence(timeout: timeout) else { return false } + if !app.staticTexts[staticText].isHittable { + return app.staticTexts[staticText].waitToBeHittable(timeout: timeout) + } + return true + } + func send(password: String? = nil) { - if app.webViews.staticTexts["Select from the following options"].waitForExistence(timeout: 1) { + if app.webViews.staticTexts["Select from the following options"].waitToBeHittable(timeout: .standard) { select(authenticator: "Password") } diff --git a/Samples/Shared/Common/Testing/XCTest+Extensions.swift b/Samples/Shared/Common/Testing/XCTest+Extensions.swift index 136656abe..710ee0f92 100644 --- a/Samples/Shared/Common/Testing/XCTest+Extensions.swift +++ b/Samples/Shared/Common/Testing/XCTest+Extensions.swift @@ -66,6 +66,18 @@ extension XCUIElement { return false } + + func waitToBeHittable(timeout: TimeInterval) -> Bool { + let timeStart = Date().timeIntervalSince1970 + + while Date().timeIntervalSince1970 <= (timeStart + timeout) { + if !exists { + return true + } + } + + return false + } } extension XCUIElementQuery {