Skip to content

Instantly share code, notes, and snippets.

@leodutra
Last active March 27, 2020 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leodutra/832d2c47bb55e9ad9b663eb955b45d86 to your computer and use it in GitHub Desktop.
Save leodutra/832d2c47bb55e9ad9b663eb955b45d86 to your computer and use it in GitHub Desktop.
waitToDisappear Swift UI Test
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