@@ -211,17 +211,11 @@ final class MFAEnrollmentUITests: XCTestCase {
211211 let phoneField = app. textFields [ " phone-number-field " ]
212212 XCTAssertTrue ( phoneField. waitForExistence ( timeout: 10 ) )
213213 let phoneNumberWithoutDialCode = " 7444555666 "
214- UIPasteboard . general. string = phoneNumberWithoutDialCode
215- phoneField. tap ( )
216- phoneField. press ( forDuration: 1.2 )
217- app. menuItems [ " Paste " ] . tap ( )
214+ try pasteIntoField ( phoneField, text: phoneNumberWithoutDialCode, app: app)
218215
219216 let displayNameField = app. textFields [ " display-name-field " ]
220217 XCTAssertTrue ( displayNameField. waitForExistence ( timeout: 10 ) )
221- UIPasteboard . general. string = " test user "
222- displayNameField. tap ( )
223- displayNameField. press ( forDuration: 1.2 )
224- app. menuItems [ " Paste " ] . tap ( )
218+ try pasteIntoField ( displayNameField, text: " test user " , app: app)
225219
226220 let sendCodeButton = app. buttons [ " send-sms-button " ]
227221 XCTAssertTrue ( sendCodeButton. waitForExistence ( timeout: 10 ) )
@@ -237,10 +231,7 @@ final class MFAEnrollmentUITests: XCTestCase {
237231 let fullPhoneNumber = " +44 \( phoneNumberWithoutDialCode) "
238232 let code = try await getLastSmsCode ( specificPhone: fullPhoneNumber)
239233
240- UIPasteboard . general. string = code
241- verificationCodeField. tap ( )
242- verificationCodeField. press ( forDuration: 1.2 )
243- app. menuItems [ " Paste " ] . tap ( )
234+ try pasteIntoField ( verificationCodeField, text: code, app: app)
244235
245236 // Test resend code button exists
246237 let resendButton = app. buttons [ " resend-code-button " ]
@@ -396,16 +387,12 @@ final class MFAEnrollmentUITests: XCTestCase {
396387 let emailField = app. textFields [ " email-field " ]
397388 XCTAssertTrue ( emailField. waitForExistence ( timeout: 10 ) , " Email field should exist " )
398389 // Workaround for updating SecureFields with ConnectHardwareKeyboard enabled
399- UIPasteboard . general. string = email
400- emailField. press ( forDuration: 1.2 )
401- app. menuItems [ " Paste " ] . tap ( )
390+ try pasteIntoField ( emailField, text: email, app: app)
402391
403392 // Fill password field
404393 let passwordField = app. secureTextFields [ " password-field " ]
405394 XCTAssertTrue ( passwordField. exists, " Password field should exist " )
406- UIPasteboard . general. string = password
407- passwordField. press ( forDuration: 1.2 )
408- app. menuItems [ " Paste " ] . tap ( )
395+ try pasteIntoField ( passwordField, text: password, app: app)
409396
410397 // Create the user (sign up)
411398 let signUpButton = app
0 commit comments