Created
March 27, 2020 02:02
-
-
Save leodutra/5f7bd6e5fd3911535acce11fc3c7685e to your computer and use it in GitHub Desktop.
waitForHittable Swift UI Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func waitForHittable(_ element: XCUIElement, timeout: TimeInterval) -> Bool { | |
let startTime = Date().timeIntervalSinceReferenceDate | |
let remainingTime = { () -> Double in | |
let diff = timeout - (Date().timeIntervalSinceReferenceDate - startTime) | |
return diff > 0 ? diff : 0 | |
} | |
if element.waitForExistence(timeout: remainingTime()) { | |
repeat { | |
if element.isHittable { | |
return true | |
} | |
sleep(1) | |
} | |
while remainingTime() > 0 | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment