snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.118.0.beta.20190314200016 vs snapshot/lib/assets/SnapshotHelper.swift in fastlane-2.118.0.beta.20190315200105
- old
+ new
@@ -154,11 +154,16 @@
print("snapshot: \(name)") // more information about this, check out https://docs.fastlane.tools/actions/snapshot/#how-does-it-work
sleep(1) // Waiting for the animation to be finished (kind of)
#if os(OSX)
- XCUIApplication().typeKey(XCUIKeyboardKeySecondaryFn, modifierFlags: [])
+ guard let app = self.app else {
+ print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ return
+ }
+
+ app.typeKey(XCUIKeyboardKeySecondaryFn, modifierFlags: [])
#else
guard let app = self.app else {
print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
return
@@ -180,11 +185,16 @@
class func waitForLoadingIndicatorToDisappear(within timeout: TimeInterval) {
#if os(tvOS)
return
#endif
- let networkLoadingIndicator = XCUIApplication().otherElements.deviceStatusBars.networkLoadingIndicators.element
+ guard let app = self.app else {
+ print("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ return
+ }
+
+ let networkLoadingIndicator = app.otherElements.deviceStatusBars.networkLoadingIndicators.element
let networkLoadingIndicatorDisappeared = XCTNSPredicateExpectation(predicate: NSPredicate(format: "exists == false"), object: networkLoadingIndicator)
_ = XCTWaiter.wait(for: [networkLoadingIndicatorDisappeared], timeout: timeout)
}
class func pathPrefix() throws -> URL? {
@@ -255,10 +265,14 @@
return self.containing(isNetworkLoadingIndicator)
}
var deviceStatusBars: XCUIElementQuery {
- let deviceWidth = XCUIApplication().windows.firstMatch.frame.width
+ guard let app = Snapshot.app else {
+ fatalError("XCUIApplication is not set. Please call setupSnapshot(app) before snapshot().")
+ }
+
+ let deviceWidth = app.windows.firstMatch.frame.width
let isStatusBar = NSPredicate { (evaluatedObject, _) in
guard let element = evaluatedObject as? XCUIElementAttributes else { return false }
return element.isStatusBar(deviceWidth)