diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php
index 4b1a421258b65785f615e9001fda0d30005f574c..7eeb093acec613c1658dc16afda7548ca2197c43 100644
--- a/core/tests/Drupal/Tests/UiHelperTrait.php
+++ b/core/tests/Drupal/Tests/UiHelperTrait.php
@@ -243,7 +243,7 @@ protected function drupalLogin(AccountInterface $account) {
       $this->drupalLogout();
     }
 
-    $this->drupalGet('user/login');
+    $this->drupalGet(Url::fromRoute('user.login'));
     $this->submitForm([
       'name' => $account->getAccountName(),
       'pass' => $account->passRaw,
@@ -267,7 +267,7 @@ protected function drupalLogout() {
     // idea being if you were properly logged out you should be seeing a login
     // screen.
     $assert_session = $this->assertSession();
-    $this->drupalGet('user/logout', ['query' => ['destination' => 'user']]);
+    $this->drupalGet(Url::fromRoute('user.logout', [], ['query' => ['destination' => 'user']]));
     $assert_session->fieldExists('name');
     $assert_session->fieldExists('pass');