Skip to content

Instantly share code, notes, and snippets.

@Morbix
Created July 8, 2016 16:44
Show Gist options
  • Save Morbix/70f1987c0f671a2d533e311b8e380967 to your computer and use it in GitHub Desktop.
Save Morbix/70f1987c0f671a2d533e311b8e380967 to your computer and use it in GitHub Desktop.
import XCTest
extension XCTestCase {
func waitForKeyboard() {
expectationForPredicate(Predicate.countEqual1, evaluatedWithObject: XCUIApplication().keyboards, handler: nil)
waitForExpectationsWithTimeout(10, handler: nil)
}
func waitForElementExist(element: XCUIElement, timeout: NSTimeInterval = 10) {
expectationForPredicate(Predicate.exists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(timeout, handler: nil)
}
func waitForElementNotExist(element: XCUIElement, timeout: NSTimeInterval = 10) {
expectationForPredicate(Predicate.notExists, evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(timeout, handler: nil)
}
}
struct Predicate {
static let countEqual1 = NSPredicate(format: "count == 1")
static let exists = NSPredicate(format: "exists == 1")
static let notExists = NSPredicate(format: "exists == 0")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment