@@ -19,9 +19,6 @@ final class AuthWebAuthnAppUITests: XCTestCase {
1919 private var deleteButton : XCUIElement !
2020 private var deleteUserButton : XCUIElement !
2121 private var springboard : XCUIApplication !
22- private var continueButton : XCUIElement ! {
23- springboard. otherElements [ " ASAuthorizationControllerContinueButton " ]
24- }
2522
2623 private lazy var deviceIdentifier : String = {
2724 let paths = Bundle . main. bundleURL. pathComponents
@@ -81,35 +78,36 @@ final class AuthWebAuthnAppUITests: XCTestCase {
8178 }
8279
8380 guard associateAttempt else {
84- XCTFail ( " Failed to trigger the Associate WebAuthn Credential workflow " )
81+ XCTFail ( " Failed to trigger the Associate WebAuthn Credential workflow: \( lastResult ) " )
8582 return
8683 }
8784
8885 // 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 " )
9189 return
9290 }
93- continueButton . tap ( )
91+ associateContinueButton . tap ( )
9492
9593 // Trigger a matching face
9694 try await matchBiometrics ( )
9795 guard waitForResult ( " WebAuthn credential was associated " ) else {
98- XCTFail ( " Failed to associate credential " )
96+ XCTFail ( " Failed to associate credential: \( lastResult ) " )
9997 return
10098 }
10199
102100 // 2. List existing credentials
103101 listButton. tap ( )
104102 guard waitForResult ( " WebAuthn Credentials: 1 " ) else {
105- XCTFail ( " Failed to list credentials " )
103+ XCTFail ( " Failed to list credentials: \( lastResult ) " )
106104 return
107105 }
108106
109107 // 3. Sign Out
110108 signOutButton. tap ( )
111109 guard waitForResult ( " User is signed out " ) , signInButton. exists else {
112- XCTFail ( " Failed to sign out user " )
110+ XCTFail ( " Failed to sign out user: \( lastResult ) " )
113111 return
114112 }
115113
@@ -120,13 +118,14 @@ final class AuthWebAuthnAppUITests: XCTestCase {
120118 }
121119
122120 guard signInAttempt else {
123- XCTFail ( " Failed to trigger the Assert WebAuthn Credential workflow " )
121+ XCTFail ( " Failed to trigger the Assert WebAuthn Credential workflow: \( lastResult ) " )
124122 return
125123 }
126124
127125 // 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 " )
130129 return
131130 }
132131
@@ -137,27 +136,27 @@ final class AuthWebAuthnAppUITests: XCTestCase {
137136 }
138137
139138 // Tap the "Continue" button
140- continueButton . tap ( )
139+ signInContinueButton . tap ( )
141140
142141 // Trigger a matching face
143142 try await matchBiometrics ( )
144143
145144 guard waitForResult ( " User is signed in " ) else {
146- XCTFail ( " Failed to Sign In with WebAuthn " )
145+ XCTFail ( " Failed to Sign In with WebAuthn: \( lastResult ) " )
147146 return
148147 }
149148
150149 // 5. Delete credential
151150 deleteButton. tap ( )
152151 guard waitForResult ( " WebAuthn credential was deleted " ) else {
153- XCTFail ( " Failed to delete credential " )
152+ XCTFail ( " Failed to delete credential: \( lastResult ) " )
154153 return
155154 }
156155
157156 // 6. Verify deletion
158157 listButton. tap ( )
159158 guard waitForResult ( " WebAuthn Credentials: 0 " ) else {
160- XCTFail ( " Failed to list credentials " )
159+ XCTFail ( " Failed to list credentials: \( lastResult ) " )
161160 return
162161 }
163162 }
@@ -194,7 +193,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
194193 return
195194 }
196195
197- username = usernameElement. label
196+ username = usernameElement. label. lowercased ( )
198197
199198 // Once the Username label exists, all these button are expected to visible as well,
200199 // so we don't wait for them and instead just check for their existence
@@ -240,7 +239,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
240239 private func signUpAndSignInUser( ) {
241240 signUpButton. tap ( )
242241 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 ) " )
244243 return
245244 }
246245 }
@@ -253,7 +252,7 @@ final class AuthWebAuthnAppUITests: XCTestCase {
253252 }
254253 deleteUserButton. tap ( )
255254 guard waitForResult ( " User was deleted " ) , signUpButton. exists else {
256- XCTFail ( " Failed to delete the user " )
255+ XCTFail ( " Failed to delete the user: \( lastResult ) " )
257256 return
258257 }
259258 }
@@ -275,4 +274,8 @@ final class AuthWebAuthnAppUITests: XCTestCase {
275274 }
276275 return result
277276 }
277+
278+ private var lastResult : String {
279+ app. staticTexts [ " LastResult " ] . label
280+ }
278281}
0 commit comments