diff SimoleonUITests/SimoleonUITests.swift @ 93:529feb1fc8d5

Added UI Tests for capture screenshots
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Tue, 03 Aug 2021 12:33:32 +0100
parents 879e20d2a837
children fa994172c050
line wrap: on
line diff
--- a/SimoleonUITests/SimoleonUITests.swift	Tue Aug 03 10:10:14 2021 +0100
+++ b/SimoleonUITests/SimoleonUITests.swift	Tue Aug 03 12:33:32 2021 +0100
@@ -11,6 +11,7 @@
 
     override func setUpWithError() throws {
         // Put setup code here. This method is called before the invocation of each test method in the class.
+        
 
         // In UI tests it is usually best to stop immediately when a failure occurs.
         continueAfterFailure = false
@@ -22,13 +23,44 @@
         // Put teardown code here. This method is called after the invocation of each test method in the class.
     }
     
-    // MARK: - Tab View
-    func testExample() throws {
+    // MARK: - Automate screenshots
+    func testScreenshots() throws {
         let app = XCUIApplication()
         setupSnapshot(app)
+        
+        // MARK: - Launch
         app.launch()
-        snapshot("01LoginScreen")
+        snapshot("0-Launch")
         
+        // MARK: - Remove 100 from conversion textfield and type custom amount
+        let conversionTextfield = app.textFields["ConversionTextfield"]
+        conversionTextfield.tap()
+        for _ in (0..<4) {
+            conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue)
+        }
+        conversionTextfield.typeText("1470.10")
+        snapshot("1-Convert")
+
+        // Remove custom amount and type again 1000
+        for _ in (0..<7) {
+            conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue)
+        }
+        conversionTextfield.typeText("1000\n")
+
+        // MARK: - Open currency selector, search BTC, and select first row
+        app.buttons["CurrencySelector"].tap()
+        snapshot("2-CurrencySelector")
+
+        let searchBar = app.textFields["SearchBar"]
+        searchBar.tap()
+        searchBar.typeText("BTC")
+        app.buttons["CurrencyRow"].firstMatch.tap()
+        snapshot("3-Bitcoin")
+
+        // MARK: - Go to favorites
+        conversionTextfield.typeText("\n")  // Dismiss keyboard
+        app.tabBars.buttons.element(boundBy: 1).tap()
+        snapshot("4-Favorites")
     }
 
     func testLaunchPerformance() throws {