diff SimoleonScreenshots/SimoleonScreenshots.swift @ 144:4271fb5f69e2

Add Scheme for automating App Preview
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Tue, 17 Aug 2021 22:15:48 +0100
parents a4aeca1ad34a
children
line wrap: on
line diff
--- a/SimoleonScreenshots/SimoleonScreenshots.swift	Tue Aug 17 08:42:00 2021 +0100
+++ b/SimoleonScreenshots/SimoleonScreenshots.swift	Tue Aug 17 22:15:48 2021 +0100
@@ -18,10 +18,6 @@
             XCUIDevice.shared.orientation = .landscapeLeft
             screenshotEndingName = "-force_landscapeleft"
         }
-        
-        let app = XCUIApplication()
-        setupSnapshot(app)
-        app.launch()
 
         // In UI tests it is usually best to stop immediately when a failure occurs.
         continueAfterFailure = false
@@ -32,8 +28,12 @@
     }
 
     func testLaunchScreenshot() throws {
+        let app = XCUIApplication()
+        setupSnapshot(app)
+        app.launch()
+        
         if UIDevice.current.userInterfaceIdiom == .pad {
-            XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap()
+            app.tables["Sidebar"].buttons["NavigateToConversion"].tap()
         }
         
         sleep(2)
@@ -41,30 +41,42 @@
     }
     
     func testConvertAmountScreenshot() throws {
+        let app = XCUIApplication()
+        setupSnapshot(app)
+        app.launch()
+        
         if UIDevice.current.userInterfaceIdiom == .pad {
-            XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap()
+            app.tables["Sidebar"].buttons["NavigateToConversion"].tap()
         }
         
-        let conversionTextField = XCUIApplication().textFields["ConversionTextField"]
+        let conversionTextField = app.textFields["ConversionTextField"]
         conversionTextField.tap()
         conversionTextField.typeText("1030.15\n")
         snapshot("2Conversion\(screenshotEndingName)")
     }
     
     func testCurrencySelectorScreenshot() throws {
+        let app = XCUIApplication()
+        setupSnapshot(app)
+        app.launch()
+        
         if UIDevice.current.userInterfaceIdiom == .pad {
-            XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap()
+            app.tables["Sidebar"].buttons["NavigateToConversion"].tap()
         }
         
-        XCUIApplication().scrollViews.buttons["OpenCurrencySelector"].tap()
+        app.scrollViews.buttons["OpenCurrencySelector"].tap()
         snapshot("3CurrencySelector\(screenshotEndingName)")
     }
     
     func testFavoriteScreenshot() throws {
+        let app = XCUIApplication()
+        setupSnapshot(app)
+        app.launch()
+        
         if UIDevice.current.userInterfaceIdiom == .pad {
-            XCUIApplication().tables["Sidebar"].buttons["NavigateToFavorites"].tap()
+            app.tables["Sidebar"].buttons["NavigateToFavorites"].tap()
         } else {
-            XCUIApplication().tabBars.buttons.element(boundBy: 1).tap()
+            app.tabBars.buttons.element(boundBy: 1).tap()
         }
         
         sleep(1)