Last active
March 27, 2020 05:44
-
-
Save leodutra/832d2c47bb55e9ad9b663eb955b45d86 to your computer and use it in GitHub Desktop.
waitToDisappear 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
func waitToDisappear(_ element: XCUIElement, timeout: TimeInterval) -> Bool { | |
let startTime = Date().timeIntervalSinceReferenceDate | |
let remainingTime = { () -> Double in | |
let diff = timeout - (Date().timeIntervalSinceReferenceDate - startTime) | |
return diff > 0 ? diff : 0 | |
} | |
repeat { | |
if !element.exists || !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