@@ -19,9 +19,6 @@ final class AuthWebAuthnAppUITests: XCTestCase {
19
19
private var deleteButton : XCUIElement !
20
20
private var deleteUserButton : XCUIElement !
21
21
private var springboard : XCUIApplication !
22
- private var continueButton : XCUIElement ! {
23
- springboard. otherElements [ " ASAuthorizationControllerContinueButton " ]
24
- }
25
22
26
23
private lazy var deviceIdentifier : String = {
27
24
let paths = Bundle . main. bundleURL. pathComponents
@@ -81,35 +78,36 @@ final class AuthWebAuthnAppUITests: XCTestCase {
81
78
}
82
79
83
80
guard associateAttempt else {
84
- XCTFail ( " Failed to trigger the Associate WebAuthn Credential workflow " )
81
+ XCTFail ( " Failed to trigger the Associate WebAuthn Credential workflow: \( lastResult ) " )
85
82
return
86
83
}
87
84
88
85
// Wait for the "Continue" button to appear in the FaceID popover and tap it
89
- guard continueButton. waitForExistence ( timeout: timeout) else {
90
- XCTFail ( " Failed to find 'Continue' button " )
86
+ let associateContinueButton = springboard. otherElements [ " ASAuthorizationControllerContinueButton " ]
87
+ guard associateContinueButton. waitForExistence ( timeout: timeout) else {
88
+ XCTFail ( " Failed to find the 'Continue' button to Associate new WebAuthn credential " )
91
89
return
92
90
}
93
- continueButton . tap ( )
91
+ associateContinueButton . tap ( )
94
92
95
93
// Trigger a matching face
96
94
try await matchBiometrics ( )
97
95
guard waitForResult ( " WebAuthn credential was associated " ) else {
98
- XCTFail ( " Failed to associate credential " )
96
+ XCTFail ( " Failed to associate credential: \( lastResult ) " )
99
97
return
100
98
}
101
99
102
100
// 2. List existing credentials
103
101
listButton. tap ( )
104
102
guard waitForResult ( " WebAuthn Credentials: 1 " ) else {
105
- XCTFail ( " Failed to list credentials " )
103
+ XCTFail ( " Failed to list credentials: \( lastResult ) " )
106
104
return
107
105
}
108
106
109
107
// 3. Sign Out
110
108
signOutButton. tap ( )
111
109
guard waitForResult ( " User is signed out " ) , signInButton. exists else {
112
- XCTFail ( " Failed to sign out user " )
110
+ XCTFail ( " Failed to sign out user: \( lastResult ) " )
113
111
return
114
112
}
115
113
@@ -120,13 +118,14 @@ final class AuthWebAuthnAppUITests: XCTestCase {
120
118
}
121
119
122
120
guard signInAttempt else {
123
- XCTFail ( " Failed to trigger the Assert WebAuthn Credential workflow " )
121
+ XCTFail ( " Failed to trigger the Assert WebAuthn Credential workflow: \( lastResult ) " )
124
122
return
125
123
}
126
124
127
125
// Wait for the "Continue" button to appear in the FaceID popover
128
- guard continueButton. waitForExistence ( timeout: timeout) else {
129
- XCTFail ( " Failed to find 'Continue' button " )
126
+ let signInContinueButton = springboard. otherElements [ " ASAuthorizationControllerContinueButton " ]
127
+ guard signInContinueButton. waitForExistence ( timeout: timeout) else {
128
+ XCTFail ( " Failed to find the 'Continue' button to Sign In with WebAuthn " )
130
129
return
131
130
}
132
131
@@ -137,27 +136,27 @@ final class AuthWebAuthnAppUITests: XCTestCase {
137
136
}
138
137
139
138
// Tap the "Continue" button
140
- continueButton . tap ( )
139
+ signInContinueButton . tap ( )
141
140
142
141
// Trigger a matching face
143
142
try await matchBiometrics ( )
144
143
145
144
guard waitForResult ( " User is signed in " ) else {
146
- XCTFail ( " Failed to Sign In with WebAuthn " )
145
+ XCTFail ( " Failed to Sign In with WebAuthn: \( lastResult ) " )
147
146
return
148
147
}
149
148
150
149
// 5. Delete credential
151
150
deleteButton. tap ( )
152
151
guard waitForResult ( " WebAuthn credential was deleted " ) else {
153
- XCTFail ( " Failed to delete credential " )
152
+ XCTFail ( " Failed to delete credential: \( lastResult ) " )
154
153
return
155
154
}
156
155
157
156
// 6. Verify deletion
158
157
listButton. tap ( )
159
158
guard waitForResult ( " WebAuthn Credentials: 0 " ) else {
160
- XCTFail ( " Failed to list credentials " )
159
+ XCTFail ( " Failed to list credentials: \( lastResult ) " )
161
160
return
162
161
}
163
162
}
@@ -194,7 +193,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
194
193
return
195
194
}
196
195
197
- username = usernameElement. label
196
+ username = usernameElement. label. lowercased ( )
198
197
199
198
// Once the Username label exists, all these button are expected to visible as well,
200
199
// so we don't wait for them and instead just check for their existence
@@ -240,7 +239,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
240
239
private func signUpAndSignInUser( ) {
241
240
signUpButton. tap ( )
242
241
guard waitForResult ( " User is signed in " ) , signOutButton. exists else {
243
- XCTFail ( " Failed to Sign Up and Sign In " )
242
+ XCTFail ( " Failed to Sign Up and Sign In: \( lastResult ) " )
244
243
return
245
244
}
246
245
}
@@ -253,7 +252,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
253
252
}
254
253
deleteUserButton. tap ( )
255
254
guard waitForResult ( " User was deleted " ) , signUpButton. exists else {
256
- XCTFail ( " Failed to delete the user " )
255
+ XCTFail ( " Failed to delete the user: \( lastResult ) " )
257
256
return
258
257
}
259
258
}
@@ -275,4 +274,8 @@ final class AuthWebAuthnAppUITests: XCTestCase {
275
274
}
276
275
return result
277
276
}
277
+
278
+ private var lastResult : String {
279
+ app. staticTexts [ " LastResult " ] . label
280
+ }
278
281
}
0 commit comments