@@ -28,40 +28,24 @@ import XCTest
2828
2929class ICKeyboardDismissTextFieldUITests : XCTestCase {
3030
31+ private lazy var app = XCUIApplication ( )
32+
3133 override func setUp( ) {
3234 super. setUp ( )
33- // In UI tests it is usually best to stop immediately when a failure occurs.
3435 continueAfterFailure = false
35- // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
3636 XCUIApplication ( ) . launch ( )
3737 }
3838
39- override func tearDown( ) {
40- // Put teardown code here. This method is called after the invocation of each test method in the class.
41- super. tearDown ( )
42- }
43-
4439 func testKeyboardDismissing( ) {
45- let app = XCUIApplication ( )
46- app. tables. cells. textFields [ " ICKeyboardDismissTextField " ] . tap ( )
47-
48- let keyboardWindow = app. children ( matching: . window) . element ( boundBy: 1 )
49- let accessory = keyboardWindow. children ( matching: . other) . element. children ( matching: . other) . element. children ( matching: . other) . element ( boundBy: 0 )
50- accessory. children ( matching: . button) . element. tap ( )
40+ app. tables. textFields [ " ICKeyboardDismissTextField " ] . tap ( )
41+ app. buttons [ " Dismiss Keyboard " ] . tap ( )
5142 }
5243
5344 func testStoryboard( ) {
54- let app = XCUIApplication ( )
55- let tablesQuery = app. tables
56-
57- tablesQuery. buttons [ " Storyboard " ] . tap ( )
58- tablesQuery. textFields [ " Storyboard ICKeyboardDismissTextField " ] . tap ( )
59-
60- let keyboardWindow = app. children ( matching: . window) . element ( boundBy: 1 )
61- let accessory = keyboardWindow. children ( matching: . other) . element. children ( matching: . other) . element. children ( matching: . other) . element ( boundBy: 0 )
62- accessory. children ( matching: . button) . element. tap ( )
63-
64- tablesQuery. buttons [ " Back to Code " ] . tap ( )
45+ app. tables. buttons [ " Storyboard " ] . tap ( )
46+ app. tables. textFields [ " Storyboard ICKeyboardDismissTextField " ] . tap ( )
47+ app. buttons [ " Dismiss Keyboard " ] . tap ( )
48+ app. tables. buttons [ " Back to Code " ] . tap ( )
6549 }
6650
6751}
0 commit comments