-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXCTestCase+Util.swift
40 lines (29 loc) · 1.18 KB
/
XCTestCase+Util.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
@package Twilio Message
@author Ryan Powell
@license MIT
*/
import Foundation
import XCTest
extension XCTestCase {
func waitForElementToAppear(_ elem: XCUIElement) {
waitForElementToAppear(elem, wait:10)
}
func waitForElementToAppear(_ elem: XCUIElement, wait: TimeInterval) {
if elem.exists { return }
let predicate = NSPredicate(format: "exists == true")
let exp = XCTNSPredicateExpectation(predicate: predicate, object: elem)
exp.expectationDescription = "waiting for \(elem) for:\(wait) seconds for element to exist"
self.wait(for: [exp], timeout: wait)
}
func waitForElementToDisappear(_ elem: XCUIElement) {
waitForElementToDisappear(elem, wait:10)
}
func waitForElementToDisappear(_ elem: XCUIElement, wait: TimeInterval) {
if !elem.exists { return }
let predicate = NSPredicate(format: "exists == false")
let exp = XCTNSPredicateExpectation(predicate: predicate, object: elem)
exp.expectationDescription = "waiting for \(elem) for:\(wait) seconds for element to cease"
self.wait(for: [exp], timeout: wait)
}
}