Skip to content

Instantly share code, notes, and snippets.

@thecb4
Created January 2, 2019 21:15
Show Gist options
  • Save thecb4/64f2cf3abefc4f889bd717a156e728b2 to your computer and use it in GitHub Desktop.
Save thecb4/64f2cf3abefc4f889bd717a156e728b2 to your computer and use it in GitHub Desktop.
ApplicationState protocol for XCUITest
typealias ApplicationState = XCTNSPredicateExpectation
protocol UIElement {
var existance: ApplicationState { get }
}
extension XCUIElement: UIElement {
var existance: ApplicationState {
let state = NSPredicate(format: "exists == true")
return ApplicationState(predicate: state, object: self)
}
}
extension Array: UIElement where Element == UIElement {
var existance: ApplicationState {
let state = NSPredicate(format: "@count > 0")
return ApplicationState(predicate: state, object: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment