comparison SimoleonAppPreview/SimoleonAppPreview.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
children 23395b98a921
comparison
equal deleted inserted replaced
143:407611b9df91 144:4271fb5f69e2
1 //
2 // SimoleonAppPreview.swift
3 // SimoleonAppPreview
4 //
5 // Created by Dennis Concepción Martín on 17/8/21.
6 //
7
8 import XCTest
9
10 class SimoleonAppPreview: XCTestCase {
11
12 override func setUpWithError() throws {
13 // This method is called before the invocation of each test method in the class.
14 if UIDevice.current.userInterfaceIdiom == .pad {
15 XCUIDevice.shared.orientation = .landscapeLeft
16 }
17
18 // In UI tests it is usually best to stop immediately when a failure occurs.
19 continueAfterFailure = false
20 }
21
22 override func tearDownWithError() throws {
23 // This method is called after the invocation of each test method in the class.
24 }
25
26 func recordInteraction(of app: XCUIApplication) {
27 app.launch()
28
29 // Write amount in textfield
30 app.textFields["ConversionTextField"].tap()
31 app.keys["4"].tap()
32 app.keys["5"].tap()
33 app.keys["0"].tap()
34 app.keys["0"].tap()
35 app.keys["0"].tap()
36
37 // Tap done to dismiss keyboard
38 app.navigationBars.buttons.element(boundBy: 0).tap()
39
40 // Open currency selector and select USD/BTC
41 app.scrollViews.buttons["OpenCurrencySelector"].tap()
42 let currencySearchBar = app.textFields["CurrencySearchBar"]
43 currencySearchBar.tap()
44 currencySearchBar.typeText("Usd/btc\n")
45 sleep(1)
46 app.tables.buttons.firstMatch.tap()
47 sleep(2)
48 }
49
50 func testUSEnglish() throws {
51 let app = XCUIApplication()
52 app.launchArguments += ["-AppleLanguages", "(en-US)"]
53 app.launchArguments += ["-AppleLocale", "\"en-US\""]
54 recordInteraction(of: app)
55 }
56
57 func testSpanish() throws {
58 let app = XCUIApplication()
59 app.launchArguments += ["-AppleLanguages", "(es-ES)"]
60 app.launchArguments += ["-AppleLocale", "\"es-ES\""]
61 recordInteraction(of: app)
62 }
63
64 func testGBEnglish() throws {
65 let app = XCUIApplication()
66 app.launchArguments += ["-AppleLanguages", "(en-GB)"]
67 app.launchArguments += ["-AppleLocale", "\"en-GB\""]
68 recordInteraction(of: app)
69 }
70
71 func testGerman() throws {
72 let app = XCUIApplication()
73 app.launchArguments += ["-AppleLanguages", "(de-DE)"]
74 app.launchArguments += ["-AppleLocale", "\"de-DE\""]
75 recordInteraction(of: app)
76 }
77
78 func testFrench() throws {
79 let app = XCUIApplication()
80 app.launchArguments += ["-AppleLanguages", "(fr-FR)"]
81 app.launchArguments += ["-AppleLocale", "\"fr-FR\""]
82 recordInteraction(of: app)
83 }
84
85 func testPortuguese() throws {
86 let app = XCUIApplication()
87 app.launchArguments += ["-AppleLanguages", "(pt-PT)"]
88 app.launchArguments += ["-AppleLocale", "\"pt-PT\""]
89 recordInteraction(of: app)
90 }
91
92 func testDutch() throws {
93 let app = XCUIApplication()
94 app.launchArguments += ["-AppleLanguages", "(nl-NL)"]
95 app.launchArguments += ["-AppleLocale", "\"nl-NL\""]
96 recordInteraction(of: app)
97 }
98
99 func testItalian() throws {
100 let app = XCUIApplication()
101 app.launchArguments += ["-AppleLanguages", "(it-IT)"]
102 app.launchArguments += ["-AppleLocale", "\"it-IT\""]
103 recordInteraction(of: app)
104 }
105
106 func testRussian() throws {
107 let app = XCUIApplication()
108 app.launchArguments += ["-AppleLanguages", "(ru-RU)"]
109 app.launchArguments += ["-AppleLocale", "\"ru-RU\""]
110 recordInteraction(of: app)
111 }
112 }