diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb
index c7ce8619aa479ce95b660e21e34f470413f875cd..c0a3ad98ca439bc7f96ee66a1cd65007317dc302 100644
--- a/spec/features/users/login_spec.rb
+++ b/spec/features/users/login_spec.rb
@@ -56,9 +56,7 @@
       expect(page).to have_current_path new_user_session_path, ignore_query: true
       expect(page).to have_content(I18n.t('devise.passwords.updated_not_active'))
 
-      fill_in 'user_login',    with: user.username
-      fill_in 'user_password', with: user.password
-      click_button 'Sign in'
+      gitlab_sign_in(user)
 
       expect_single_session_with_authenticated_ttl
       expect(page).to have_current_path root_path, ignore_query: true
@@ -209,10 +207,14 @@
 
   describe 'with two-factor authentication', :js do
     def enter_code(code, only_two_factor_webauthn_enabled: false)
-      click_on("Sign in via 2FA code") if only_two_factor_webauthn_enabled
+      if only_two_factor_webauthn_enabled
+        # When this button is visible we know that the JavaScript functionality is ready.
+        find_button(_('Try again?'))
+        click_button _("Sign in via 2FA code")
+      end
 
-      fill_in 'user_otp_attempt', with: code
-      click_button 'Verify code'
+      fill_in _('Enter verification code'), with: code
+      click_button _('Verify code')
     end
 
     shared_examples_for 'can login with recovery codes' do |only_two_factor_webauthn_enabled: false|
@@ -574,9 +576,7 @@ def sign_in_using_saml!
 
           visit new_user_session_path
 
-          fill_in 'user_login', with: user.email
-          fill_in 'user_password', with: user.password
-          click_button 'Sign in'
+          gitlab_sign_in(user)
 
           expect(page).to have_current_path(new_user_settings_password_path, ignore_query: true)
         end
@@ -938,13 +938,9 @@ def sign_in_using_saml!
 
       visit new_user_session_path
 
-      fill_in 'user_login', with: user.email
-      fill_in 'user_password', with: user.password
-
-      click_button 'Sign in'
+      gitlab_sign_in(user)
 
       expect_to_be_on_terms_page
-
       click_button 'Accept terms'
 
       expect(page).to have_current_path(root_path, ignore_query: true)
@@ -959,10 +955,7 @@ def sign_in_using_saml!
 
       visit new_user_session_path
 
-      fill_in 'user_login', with: user.email
-      fill_in 'user_password', with: user.password
-
-      click_button 'Sign in'
+      gitlab_sign_in(user)
 
       expect(page).to have_current_path(root_path, ignore_query: true)
     end
@@ -980,10 +973,7 @@ def sign_in_using_saml!
 
           visit new_user_session_path
 
-          fill_in 'user_login', with: user.email
-          fill_in 'user_password', with: user.password
-
-          click_button 'Sign in'
+          gitlab_sign_in(user)
 
           expect_to_be_on_terms_page
           click_button 'Accept terms'
@@ -1022,12 +1012,7 @@ def sign_in_using_saml!
 
           visit new_user_session_path
 
-          fill_in 'user_login', with: user.email
-          fill_in 'user_password', with: user.password
-          click_button 'Sign in'
-
-          fill_in 'user_otp_attempt', with: user.reload.current_otp
-          click_button 'Verify code'
+          gitlab_sign_in(user, two_factor_auth: true)
 
           expect_to_be_on_terms_page
           click_button 'Accept terms'
@@ -1048,9 +1033,7 @@ def sign_in_using_saml!
 
         visit new_user_session_path
 
-        fill_in 'user_login', with: user.email
-        fill_in 'user_password', with: user.password
-        click_button 'Sign in'
+        gitlab_sign_in(user)
 
         expect_to_be_on_terms_page
         click_button 'Accept terms'
diff --git a/spec/support/helpers/admin_mode_helpers.rb b/spec/support/helpers/admin_mode_helpers.rb
index 8b71552f9285cbbc6964d4a8c7c3097d5799ecd9..630c126adf43b8f187945cdba7fcbe3fb632eba9 100644
--- a/spec/support/helpers/admin_mode_helpers.rb
+++ b/spec/support/helpers/admin_mode_helpers.rb
@@ -18,6 +18,12 @@ module AdminModeHelper
   def enable_admin_mode!(user, use_ui: false)
     if use_ui
       visit new_admin_session_path
+
+      # When JavaScript is enabled, wait for the password field, with class `.js-password`,
+      # to be replaced by the Vue passsword component,
+      # `app/assets/javascripts/authentication/password/components/password_input.vue`.
+      expect(page).not_to have_selector('.js-password') if javascript_test?
+
       fill_in 'user_password', with: user.password
       click_button 'Enter admin mode'
 
diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb
index 3b530465a3bd34bffb7b14c7b107ee88d645dc5d..2f676bae8b9d136ee3b8ebcd17da9e6fd9fec5c9 100644
--- a/spec/support/helpers/login_helpers.rb
+++ b/spec/support/helpers/login_helpers.rb
@@ -94,7 +94,14 @@ def gitlab_sign_in_with(user, remember: false, two_factor_auth: false, password:
     visit new_user_session_path if visit
 
     fill_in "user_login", with: user.email
+
+    # When JavaScript is enabled, wait for the password field, with class `.js-password`,
+    # to be replaced by the Vue passsword component,
+    # `app/assets/javascripts/authentication/password/components/password_input.vue`.
+    expect(page).not_to have_selector('.js-password') if javascript_test?
+
     fill_in "user_password", with: (password || user.password)
+
     check 'user_remember_me' if remember
 
     wait_for_all_requests