Mercurial > public > simoleon
comparison SimoleonScreenshots/SimoleonScreenshots.swift @ 133:f54d3dabb2d3
Update test for screenshots
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 16 Aug 2021 18:22:55 +0100 |
parents | 587924519d3b |
children | a4aeca1ad34a |
comparison
equal
deleted
inserted
replaced
132:9439c76e6590 | 133:f54d3dabb2d3 |
---|---|
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 5/8/21. | 5 // Created by Dennis Concepción Martín on 5/8/21. |
6 // | 6 // |
7 | 7 |
8 import XCTest | 8 import XCTest |
9 | 9 import CoreData |
10 // Automate screenshots with Fastlane | |
10 class SimoleonScreenshots: XCTestCase { | 11 class SimoleonScreenshots: XCTestCase { |
11 var screnshotEndingName = "" | 12 var screnshotEndingName = "" |
12 | 13 |
13 override func setUpWithError() throws { | 14 override func setUpWithError() throws { |
14 // Put setup code here. This method is called before the invocation of each test method in the class. | 15 // This method is called before the invocation of each test method in the class. |
16 | |
15 if UIDevice.current.userInterfaceIdiom == .pad { | 17 if UIDevice.current.userInterfaceIdiom == .pad { |
16 XCUIDevice.shared.orientation = .landscapeLeft | 18 XCUIDevice.shared.orientation = .landscapeLeft |
17 screnshotEndingName = "-force_landscapeleft" | 19 screnshotEndingName = "-force_landscapeleft" |
18 } | 20 } |
19 | 21 |
21 setupSnapshot(app) | 23 setupSnapshot(app) |
22 app.launch() | 24 app.launch() |
23 | 25 |
24 // In UI tests it is usually best to stop immediately when a failure occurs. | 26 // In UI tests it is usually best to stop immediately when a failure occurs. |
25 continueAfterFailure = false | 27 continueAfterFailure = false |
26 | |
27 // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. | |
28 } | 28 } |
29 | 29 |
30 override func tearDownWithError() throws { | 30 override func tearDownWithError() throws { |
31 // Put teardown code here. This method is called after the invocation of each test method in the class. | 31 // Put teardown code here. This method is called after the invocation of each test method in the class. |
32 } | 32 } |
33 | 33 |
34 // MARK: - Automate screenshots | 34 func testLaunchScreenshot() throws { |
35 func testLaunch() { | |
36 if UIDevice.current.userInterfaceIdiom == .pad { | 35 if UIDevice.current.userInterfaceIdiom == .pad { |
37 XCUIApplication().tables.buttons.firstMatch.tap() | 36 XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap() |
38 } | 37 } |
39 | 38 |
39 sleep(2) | |
40 snapshot("1Launch\(screnshotEndingName)") | 40 snapshot("1Launch\(screnshotEndingName)") |
41 } | 41 } |
42 | 42 |
43 func testCurrencySelector() { | 43 func testConvertAmountScreenshot() throws { |
44 if UIDevice.current.userInterfaceIdiom == .pad { | 44 if UIDevice.current.userInterfaceIdiom == .pad { |
45 XCUIApplication().tables.buttons.firstMatch.tap() | 45 XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap() |
46 } | 46 } |
47 | 47 |
48 XCUIApplication().scrollViews.buttons.firstMatch.tap() | 48 let conversionTextField = XCUIApplication().textFields["ConversionTextField"] |
49 snapshot("2CurrencySelector\(screnshotEndingName)") | 49 conversionTextField.tap() |
50 | 50 conversionTextField.typeText("1030.15\n") |
51 XCUIApplication().tables.buttons.element(boundBy: 6).tap() | 51 snapshot("2Conversion\(screnshotEndingName)") |
52 let conversionTextfield = XCUIApplication().textFields.firstMatch | 52 } |
53 conversionTextfield.tap() | 53 |
54 for _ in (0..<4) { | 54 func testCurrencySelectorScreenshot() throws { |
55 conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) | 55 if UIDevice.current.userInterfaceIdiom == .pad { |
56 XCUIApplication().tables["Sidebar"].buttons["NavigateToConversion"].tap() | |
56 } | 57 } |
57 | 58 |
58 conversionTextfield.typeText("\n") | 59 XCUIApplication().scrollViews.buttons["OpenCurrencySelector"].tap() |
59 | 60 snapshot("3CurrencySelector\(screnshotEndingName)") |
60 snapshot("3Amount\(screnshotEndingName)") | |
61 } | 61 } |
62 | 62 |
63 func testFavorites() throws { | 63 func testFavoriteScreenshot() throws { |
64 // Go to favorites | |
65 if UIDevice.current.userInterfaceIdiom == .pad { | 64 if UIDevice.current.userInterfaceIdiom == .pad { |
66 XCUIApplication().tables.buttons.element(boundBy: 1).tap() | 65 XCUIApplication().tables["Sidebar"].buttons["NavigateToFavorites"].tap() |
67 } else { | 66 } else { |
68 XCUIApplication().tabBars.buttons.element(boundBy: 1).tap() | 67 XCUIApplication().tabBars.buttons.element(boundBy: 1).tap() |
69 } | 68 } |
70 | 69 |
70 sleep(1) | |
71 | |
71 snapshot("4Favorites\(screnshotEndingName)") | 72 snapshot("4Favorites\(screnshotEndingName)") |
72 } | 73 } |
73 } | 74 } |