lib/assets/SnapshotHelper.swift in snapshot-1.5.0 vs lib/assets/SnapshotHelper.swift in snapshot-1.6.0
- old
+ new
@@ -18,11 +18,11 @@
func setupSnapshot(app: XCUIApplication) {
Snapshot.setupSnapshot(app)
}
-func snapshot(name: String, waitForLoadingIndicator: Bool = false) {
+func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
Snapshot.snapshot(name, waitForLoadingIndicator: waitForLoadingIndicator)
}
class Snapshot: NSObject {
@@ -59,11 +59,11 @@
} catch {
print("Couldn't detect/set launch_arguments...")
}
}
- class func snapshot(name: String, waitForLoadingIndicator: Bool = false) {
+ class func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
if waitForLoadingIndicator {
waitForLoadingIndicatorToDisappear()
}
print("snapshot: \(name)") // more information about this, check out https://github.com/fastlane/snapshot
@@ -73,15 +73,19 @@
}
class func waitForLoadingIndicatorToDisappear() {
let query = XCUIApplication().statusBars.childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other)
- let expectedCount = ((UIDevice.currentDevice().userInterfaceIdiom == .Pad) ? 5 : 4)
-
- while (query.count > UInt(expectedCount)) {
+ while (0..<query.count).map({ query.elementBoundByIndex($0) }).contains({ $0.isLoadingIndicator }) {
sleep(1)
- print("Number of Elements in Status Bar: \(query.count)... waiting for status bar to disappear")
+ print("Waiting for loading indicator to disappear...")
}
+ }
+}
+
+extension XCUIElement {
+ var isLoadingIndicator: Bool {
+ return self.frame.size == CGSize(width: 10, height: 20)
}
}
// Please don't remove the lines below
// They are used to detect outdated configuration files