@@ -28,17 +28,15 @@ import XCTest
2828
2929class ICTokenFieldUITests : XCTestCase {
3030
31+ private lazy var app = XCUIApplication ( )
32+
3133 override func setUp( ) {
3234 super. setUp ( )
3335 continueAfterFailure = false
34- XCUIApplication ( ) . launch ( )
36+ app . launch ( )
3537 }
3638
37- func testTokenField( ) {
38- let app = XCUIApplication ( )
39- let tablesQuery = app. tables
40- let textField = tablesQuery. cells. containing ( . staticText, identifier: " ICTokenField " ) . children ( matching: . textField) . element
41-
39+ private func typeTexts( in textField: XCUIElement ) {
4240 textField. tap ( )
4341 textField. typeText ( " Try " )
4442 textField. typeText ( " " )
@@ -54,58 +52,25 @@ class ICTokenFieldUITests: XCTestCase {
5452 textField. typeText ( " TestFlight " )
5553 textField. typeText ( " , " )
5654
57- let searchButton = app. buttons [ " Search " ]
58- searchButton. tap ( )
55+ app. buttons [ " Search " ] . tap ( )
56+ }
57+
58+ func testTokenField( ) {
59+ let textField = app. tables. cells. containing ( . staticText, identifier: " ICTokenField " ) . children ( matching: . textField) . element
60+ typeTexts ( in: textField)
5961 }
6062
6163 func testCustomizedTokenField( ) {
62- let app = XCUIApplication ( )
6364 app. tables. staticTexts [ " CustomizedTokenField " ] . tap ( )
64-
6565 let tokenField = app. navigationBars [ " Example.CustomizedTokenView " ] . scrollViews. children ( matching: . textField) . element
66- tokenField. typeText ( " Try " )
67- tokenField. typeText ( " " )
68- tokenField. typeText ( " iCook " )
69- tokenField. typeText ( " , " )
70- tokenField. typeText ( " beta " )
71- tokenField. typeText ( " " )
72-
73- let deleteKey = app. keys [ " delete " ]
74- deleteKey. tap ( )
75- deleteKey. tap ( )
76-
77- tokenField. typeText ( " TestFlight " )
78- tokenField. typeText ( " , " )
79-
80- let searchButton = app. buttons [ " Search " ]
81- searchButton. tap ( )
66+ typeTexts ( in: tokenField)
8267 }
8368
8469 func testStoryboard( ) {
85- let app = XCUIApplication ( )
86- let tablesQuery = app. tables
87- tablesQuery. buttons [ " Storyboard " ] . tap ( )
88-
89- let tokenField = tablesQuery. cells. containing ( . staticText, identifier: " Storyboard ICTokenField " ) . children ( matching: . textField) . element
90- tokenField. tap ( )
91- tokenField. typeText ( " Try " )
92- tokenField. typeText ( " " )
93- tokenField. typeText ( " iCook " )
94- tokenField. typeText ( " , " )
95- tokenField. typeText ( " beta " )
96- tokenField. typeText ( " " )
97-
98- let deleteKey = app. keys [ " delete " ]
99- deleteKey. tap ( )
100- deleteKey. tap ( )
101-
102- tokenField. typeText ( " TestFlight " )
103- tokenField. typeText ( " , " )
104-
105- let searchButton = app. buttons [ " Search " ]
106- searchButton. tap ( )
107-
108- tablesQuery. buttons [ " Back to Code " ] . tap ( )
70+ app. tables. buttons [ " Storyboard " ] . tap ( )
71+ let tokenField = app. tables. cells. containing ( . staticText, identifier: " Storyboard ICTokenField " ) . children ( matching: . textField) . element
72+ typeTexts ( in: tokenField)
73+ app. tables. buttons [ " Back to Code " ] . tap ( )
10974 }
11075
11176}
0 commit comments