From 89da8c8d520bf5745f5d9ffe989cc102f7fd47d7 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 6 Aug 2021 08:21:30 +0100
Subject: [PATCH] Issue #3170396 by mondrake, longwave: Remove uses of t() in
 assert(No)Raw() calls

---
 .../src/Functional/ConfigurationTest.php      |  2 +-
 .../tests/src/Functional/AddFeedTest.php      |  4 +-
 .../src/Functional/AggregatorTestBase.php     |  4 +-
 .../tests/src/Functional/FeedParserTest.php   |  2 +-
 .../tests/src/Functional/ImportOpmlTest.php   |  8 +-
 .../src/Functional/IpAddressBlockingTest.php  |  4 +-
 .../src/Functional/BlockInvalidRegionTest.php |  8 +-
 .../block/tests/src/Functional/BlockTest.php  |  8 +-
 .../Functional/BlockContentCreationTest.php   | 28 ++----
 .../Functional/BlockContentPageViewTest.php   |  2 +-
 .../BlockContentTranslationUITest.php         |  8 +-
 .../src/Functional/BlockContentTypeTest.php   |  8 +-
 .../book/tests/src/Functional/BookTest.php    |  8 +-
 .../src/Functional/CKEditorAdminTest.php      |  2 +-
 .../CKEditorStylesComboAdminTest.php          |  2 +-
 .../src/Functional/CommentAnonymousTest.php   |  8 +-
 .../src/Functional/CommentNonNodeTest.php     |  2 +-
 .../tests/src/Functional/CommentPagerTest.php |  4 +-
 .../tests/src/Functional/CommentTestBase.php  |  2 +-
 .../Functional/CommentTranslationUITest.php   |  8 +-
 .../tests/src/Functional/CommentTypeTest.php  | 17 +---
 .../tests/src/Functional/ConfigEntityTest.php | 21 ++--
 .../src/Functional/ConfigImportUITest.php     |  6 +-
 .../src/Functional/ConfigImportUploadTest.php |  2 +-
 .../src/Functional/ConfigInstallWebTest.php   |  2 +-
 .../ConfigSingleImportExportTest.php          | 27 +++---
 .../ConfigTranslationListUiTest.php           |  2 +-
 .../Functional/ConfigTranslationUiTest.php    | 18 ++--
 .../src/Functional/ContactPersonalTest.php    |  7 +-
 .../src/Functional/ContactSitewideTest.php    | 10 +-
 .../ContentTranslationContextualLinksTest.php |  2 +-
 .../dblog/tests/src/Functional/DbLogTest.php  |  2 +-
 .../field/tests/src/Functional/FormTest.php   |  8 +-
 .../tests/src/Functional/NestedFormTest.php   |  4 +-
 .../src/Functional/Number/NumberFieldTest.php | 20 ++--
 .../src/Functional/EntityDisplayModeTest.php  | 12 +--
 .../src/Functional/ManageDisplayTest.php      |  3 +-
 .../Functional/ManageFieldsFunctionalTest.php | 14 +--
 .../tests/src/Traits/FieldUiTestTrait.php     | 12 +--
 .../src/Functional/FileFieldValidateTest.php  | 12 +--
 .../src/Functional/FileFieldWidgetTest.php    |  5 +-
 .../Functional/FileManagedFileElementTest.php | 14 +--
 .../src/Functional/SaveUploadFormTest.php     | 78 +++++++--------
 .../tests/src/Functional/SaveUploadTest.php   | 95 +++++++++----------
 .../FileFieldWidgetTest.php                   |  8 +-
 .../tests/src/Functional/FilterAdminTest.php  | 14 ++-
 .../tests/src/Functional/FilterHooksTest.php  |  6 +-
 .../forum/tests/src/Functional/ForumTest.php  | 10 +-
 .../help/tests/src/Functional/HelpTest.php    |  4 +-
 .../src/Functional/ImageAdminStylesTest.php   | 16 ++--
 .../src/Functional/ImageFieldDisplayTest.php  | 10 +-
 .../src/Functional/ImageFieldValidateTest.php | 12 +--
 .../src/Functional/ImageStyleDeleteTest.php   | 16 ++--
 .../AdminPathEntityConverterLanguageTest.php  |  8 +-
 .../LanguageBrowserDetectionTest.php          | 11 +--
 .../Functional/LanguageConfigurationTest.php  |  2 +-
 ...anguageCustomLanguageConfigurationTest.php | 25 ++---
 .../tests/src/Functional/LanguageListTest.php | 12 +--
 .../LanguageNegotiationInfoTest.php           |  4 +-
 .../LanguageUILanguageNegotiationTest.php     |  2 +-
 .../src/Functional/LocaleContentTest.php      |  4 +-
 .../Functional/LocaleImportFunctionalTest.php | 31 +++---
 .../Functional/LocaleTranslationUiTest.php    |  4 +-
 .../Functional/LocaleUpdateInterfaceTest.php  |  9 +-
 .../tests/src/Functional/LocaleUpdateTest.php |  6 +-
 .../MenuLinkContentDeleteFormTest.php         |  4 +-
 .../MenuLinkContentTranslationUITest.php      |  7 +-
 .../tests/src/Functional/MenuUiNodeTest.php   |  4 +-
 .../tests/src/Functional/MenuUiTest.php       | 25 ++---
 .../NodeActionsConfigurationTest.php          |  2 +-
 .../tests/src/Functional/NodeEditFormTest.php |  2 +-
 .../Functional/NodeFieldMultilingualTest.php  |  2 +-
 .../src/Functional/NodeRevisionsAllTest.php   | 20 +---
 .../src/Functional/NodeRevisionsTest.php      | 18 +---
 .../src/Functional/NodeTranslationUITest.php  |  8 +-
 .../tests/src/Functional/NodeTypeTest.php     | 14 +--
 .../Functional/NodeTypeTranslationTest.php    |  4 +-
 .../src/Functional/OptionsWidgetsTest.php     |  2 +-
 .../tests/src/Functional/PathAliasTest.php    | 11 +--
 .../src/Functional/SearchCommentTest.php      |  2 +-
 .../SearchConfigSettingsFormTest.php          | 10 +-
 .../src/Functional/SearchPageTextTest.php     |  2 +-
 .../src/Functional/ShortcutLinksTest.php      |  2 +-
 .../tests/src/Functional/ShortcutSetsTest.php |  2 +-
 .../Functional/ShortcutTranslationUITest.php  |  7 +-
 .../Bootstrap/DrupalMessengerServiceTest.php  |  2 +-
 .../Entity/EntityTranslationFormTest.php      |  2 +-
 .../tests/src/Functional/Form/EmailTest.php   |  4 +-
 .../tests/src/Functional/Form/FormTest.php    |  4 +-
 .../Form/StateValuesCleanAdvancedTest.php     |  2 +-
 .../tests/src/Functional/Form/UrlTest.php     |  4 +-
 .../src/Functional/Form/ValidationTest.php    | 32 +++----
 .../src/Functional/Module/DependencyTest.php  | 14 ++-
 .../RenderArrayNonHtmlSubscriberTest.php      |  6 +-
 .../src/Functional/System/DateTimeTest.php    |  2 +-
 .../Functional/System/SiteMaintenanceTest.php |  8 +-
 .../src/Functional/System/StatusTest.php      |  2 +-
 .../Functional/System/TrustedHostsTest.php    |  8 +-
 .../src/Functional/TermTranslationUITest.php  |  7 +-
 .../Functional/VocabularyPermissionsTest.php  |  8 +-
 .../tests/src/Functional/VocabularyUiTest.php |  6 +-
 .../tests/src/Functional/UpdateUploadTest.php |  4 +-
 .../tests/src/Functional/UserCancelTest.php   | 24 ++---
 .../tests/src/Functional/UserCreateTest.php   |  4 +-
 .../tests/src/Functional/UserEditTest.php     | 18 ++--
 .../tests/src/Functional/UserLoginTest.php    |  8 +-
 .../src/Functional/UserPasswordResetTest.php  |  5 +-
 .../src/Functional/UserRegistrationTest.php   |  4 +-
 .../src/Functional/UserRoleAdminTest.php      |  8 +-
 .../src/Functional/UserTranslationUITest.php  |  7 +-
 .../Views/HandlerFilterUserNameTest.php       | 10 +-
 .../Functional/Plugin/ArgumentDefaultTest.php |  8 +-
 .../src/Functional/Plugin/ExposedFormTest.php |  4 +-
 .../tests/src/Functional/Wizard/BasicTest.php |  2 +-
 .../tests/src/Functional/CachedDataUITest.php |  2 +-
 .../tests/src/Functional/DisplayPathTest.php  |  2 +-
 .../tests/src/Functional/ViewEditTest.php     |  2 +-
 ...nEnglishProfileWithoutLocaleModuleTest.php |  4 +-
 .../Installer/InstallerTest.php               |  4 +-
 119 files changed, 470 insertions(+), 638 deletions(-)

diff --git a/core/modules/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php
index 2a8d1b421980..051ba5032b73 100644
--- a/core/modules/action/tests/src/Functional/ConfigurationTest.php
+++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php
@@ -89,7 +89,7 @@ public function testActionConfiguration() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Make sure that the action was actually deleted.
-    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]));
+    $this->assertSession()->pageTextContains("The action $new_action_label has been deleted.");
     $this->drupalGet('admin/config/system/actions');
     $this->assertSession()->statusCodeEquals(200);
     // The action label does not appear on the overview page.
diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
index 09917dc57e8f..5b19c3672710 100644
--- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
@@ -48,8 +48,8 @@ public function testAddFeed() {
     ];
     $this->drupalGet('aggregator/sources/add');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
-    $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
+    $this->assertSession()->pageTextContains('A feed named ' . $feed->label() . ' already exists. Enter a unique title.');
+    $this->assertSession()->pageTextContains('A feed with this URL ' . $feed->getUrl() . ' already exists. Enter a unique URL.');
 
     // Delete feed.
     $this->deleteFeed($feed);
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
index a1ca558c30a2..3e5ce2503265 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
@@ -99,7 +99,7 @@ public function createFeed($feed_url = NULL, array $edit = []) {
   public function deleteFeed(FeedInterface $feed) {
     $this->drupalGet('aggregator/sources/' . $feed->id() . '/delete');
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
+    $this->assertSession()->pageTextContains('The feed ' . $feed->label() . ' has been deleted.');
   }
 
   /**
@@ -222,7 +222,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
   public function deleteFeedItems(FeedInterface $feed) {
     $this->drupalGet('admin/config/services/aggregator/delete/' . $feed->id());
     $this->submitForm([], 'Delete items');
-    $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
+    $this->assertSession()->pageTextContains('The news items from ' . $feed->label() . ' have been deleted.');
   }
 
   /**
diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
index bdbfe0833b96..193a222145b2 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
@@ -119,7 +119,7 @@ public function testInvalidFeed() {
     // Update the feed. Use the UI to be able to check the message easily.
     $this->drupalGet('admin/config/services/aggregator');
     $this->clickLink('Update items');
-    $this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
+    $this->assertSession()->pageTextContains('The feed from ' . $feed->label() . ' seems to be broken because of error');
   }
 
 }
diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
index a690fbd72221..05ad90d2b749 100644
--- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
@@ -63,7 +63,7 @@ public function validateImportFormFields() {
     $edit = [];
     $this->drupalGet('admin/config/services/aggregator/add/opml');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
+    $this->assertSession()->pageTextContains('Either upload a file or enter a URL.');
 
     $path = $this->getEmptyOpml();
     $edit = [
@@ -72,7 +72,7 @@ public function validateImportFormFields() {
     ];
     $this->drupalGet('admin/config/services/aggregator/add/opml');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
+    $this->assertSession()->pageTextContains('Either upload a file or enter a URL.');
 
     // Error if the URL is invalid.
     $edit = ['remote' => 'invalidUrl://empty'];
@@ -120,9 +120,9 @@ protected function submitImportForm() {
     $this->drupalGet('admin/config/services/aggregator/add/opml');
     $this->submitForm($edit, 'Import');
     // Verify that a duplicate URL was identified.
-    $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]));
+    $this->assertSession()->pageTextContains('A feed with the URL ' . $feeds[0]['url[0][value]'] . ' already exists.');
     // Verify that a duplicate title was identified.
-    $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]));
+    $this->assertSession()->pageTextContains('A feed named ' . $feeds[1]['title[0][value]'] . ' already exists.');
 
     $after = $count_query->execute();
     $this->assertEquals(2, $after, 'Verifying that two distinct feeds were added.');
diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
index 93774f84538f..aeed41b40e0b 100644
--- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
+++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
@@ -42,7 +42,7 @@ public function testIPAddressValidation() {
     $this->submitForm($edit, 'Add');
     $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
     $this->assertNotEmpty($ip, 'IP address found in database.');
-    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]));
+    $this->assertSession()->pageTextContains('The IP address 1.2.3.3 has been banned.');
 
     // Try to block an IP address that's already blocked.
     $edit = [];
@@ -78,7 +78,7 @@ public function testIPAddressValidation() {
     $this->submitForm([], 'Add');
     $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $submit_ip)->execute()->fetchField();
     $this->assertNotEmpty($ip, 'IP address found in database');
-    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]));
+    $this->assertSession()->pageTextContains("The IP address $submit_ip has been banned.");
 
     // Submit your own IP address. This fails, although it works when testing
     // manually.
diff --git a/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
index 9a82471fbc99..6a9d5cba542a 100644
--- a/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
+++ b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
@@ -45,17 +45,17 @@ public function testBlockInInvalidRegion() {
     \Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
     $block = Block::load($block->id());
 
-    $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block->id(), '%region' => 'invalid_region']);
+    $warning_message = 'The block ' . $block->id() . ' was assigned to the invalid region invalid_region and has been disabled.';
 
     // Clearing the cache should disable the test block placed in the invalid region.
     $this->drupalGet('admin/config/development/performance');
     $this->submitForm([], 'Clear all caches');
-    $this->assertRaw($warning_message);
+    $this->assertSession()->pageTextContains($warning_message);
 
     // Clear the cache to check if the warning message is not triggered.
     $this->drupalGet('admin/config/development/performance');
     $this->submitForm([], 'Clear all caches');
-    $this->assertNoRaw($warning_message);
+    $this->assertSession()->pageTextNotContains($warning_message);
 
     // Place disabled test block in the invalid region of the default theme.
     \Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
@@ -64,7 +64,7 @@ public function testBlockInInvalidRegion() {
     // Clear the cache to check if the warning message is not triggered.
     $this->drupalGet('admin/config/development/performance');
     $this->submitForm([], 'Clear all caches');
-    $this->assertNoRaw($warning_message);
+    $this->assertSession()->pageTextNotContains($warning_message);
   }
 
 }
diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php
index 3d78821e9eba..1663175b1bcd 100644
--- a/core/modules/block/tests/src/Functional/BlockTest.php
+++ b/core/modules/block/tests/src/Functional/BlockTest.php
@@ -247,17 +247,17 @@ public function testBlock() {
     // Test deleting the block from the edit form.
     $this->drupalGet('admin/structure/block/manage/' . $block['id']);
     $this->clickLink('Remove block');
-    $this->assertRaw(t('Are you sure you want to remove the block @name from the @region region?', ['@name' => $block['settings[label]'], '@region' => 'Footer']));
+    $this->assertSession()->pageTextContains('Are you sure you want to remove the block ' . $block['settings[label]'] . ' from the Footer region?');
     $this->submitForm([], 'Remove');
-    $this->assertRaw(t('The block %name has been removed from the %region region.', ['%name' => $block['settings[label]'], '%region' => 'Footer']));
+    $this->assertSession()->pageTextContains('The block ' . $block['settings[label]'] . ' has been removed from the Footer region.');
 
     // Test deleting a block via "Configure block" link.
     $block = $this->drupalPlaceBlock('system_powered_by_block');
     $this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]);
     $this->clickLink('Remove block');
-    $this->assertRaw(t('Are you sure you want to remove the block @name from the @region region?', ['@name' => $block->label(), '@region' => 'Left sidebar']));
+    $this->assertSession()->pageTextContains('Are you sure you want to remove the block ' . $block->label() . ' from the Left sidebar region?');
     $this->submitForm([], 'Remove');
-    $this->assertRaw(t('The block %name has been removed from the %region region.', ['%name' => $block->label(), '%region' => 'Left sidebar']));
+    $this->assertSession()->pageTextContains('The block ' . $block->label() . ' has been removed from the Left sidebar region.');
     $this->assertSession()->addressEquals('admin');
     $this->assertNoRaw($block->id());
   }
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
index ebe9fcd98887..913c1ac10160 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\block_content\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\block_content\Entity\BlockContent;
 use Drupal\Core\Database\Database;
 
@@ -60,10 +59,7 @@ public function testBlockContentCreation() {
     $this->submitForm($edit, 'Save');
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
-      '@block' => 'basic',
-      '%name' => $edit['info[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
 
     // Check that the view mode setting is hidden because only one exists.
     $this->assertSession()->fieldNotExists('settings[view_mode]');
@@ -81,9 +77,7 @@ public function testBlockContentCreation() {
     $this->submitForm($edit, 'Save');
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
-      '%value' => $edit['info[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains('A custom block with block description ' . $edit['info[0][value]'] . ' already exists.');
     $this->assertSession()->statusCodeEquals(200);
   }
 
@@ -99,7 +93,7 @@ public function testBlockContentCreationMultipleViewModes() {
       'label' => 'Test View Mode',
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains('Saved the ' . $edit['label'] . ' view mode.');
 
     $this->drupalLogin($this->adminUser);
 
@@ -111,10 +105,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->submitForm($edit, 'Save');
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
-      '@block' => 'basic',
-      '%name' => $edit['info[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
 
     // Save our block permanently
     $this->submitForm(['region' => 'content'], 'Save block');
@@ -167,9 +158,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->submitForm($edit, 'Save');
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
-      '%value' => $edit['info[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains('A custom block with block description ' . $edit['info[0][value]'] . ' already exists.');
     $this->assertSession()->statusCodeEquals(200);
   }
 
@@ -188,10 +177,7 @@ public function testDefaultBlockContentCreation() {
     $this->submitForm($edit, 'Save');
 
     // Check that the block has been created and that it is a basic block.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
-      '@block' => 'basic',
-      '%name' => $edit['info[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
 
     // Check that the block exists in the database.
     $blocks = \Drupal::entityTypeManager()
@@ -262,7 +248,7 @@ public function testBlockDelete() {
     $this->assertSession()->pageTextContains('This will also remove 1 placed block instance.');
 
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']]));
+    $this->assertSession()->pageTextContains('The custom block ' . $edit['info[0][value]'] . ' has been deleted.');
 
     // Create another block and force the plugin cache to flush.
     $edit2 = [];
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
index b2111370b60d..743903caefbe 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
@@ -34,7 +34,7 @@ public function testPageEdit() {
     // Ensure user was able to view the block.
     $this->assertSession()->statusCodeEquals(200);
     $this->drupalGet('<front>');
-    $this->assertRaw(t('This block is broken or missing. You may be missing content or you might need to enable the original module.'));
+    $this->assertSession()->pageTextContains('This block is broken or missing. You may be missing content or you might need to enable the original module.');
   }
 
 }
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
index 3d765ac95a3a..3d93ed33e854 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
@@ -145,13 +145,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('<em>Edit @type</em> @title [%language translation]', [
-          '@type' => $entity->bundle(),
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("Edit {$entity->bundle()} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
index 44fff904e0c9..7179d9af5019 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
@@ -175,18 +175,14 @@ public function testBlockContentTypeDeletion() {
     $block = $this->createBlockContent(FALSE, 'foo');
     // Attempt to delete the block type, which should not be allowed.
     $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
-      t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()])
-    );
+    $this->assertSession()->pageTextContains($type->label() . ' is used by 1 custom block on your site. You can not remove this block type until you have removed all of the ' . $type->label() . ' blocks.');
     $this->assertSession()->pageTextNotContains('This action cannot be undone.');
 
     // Delete the block.
     $block->delete();
     // Attempt to delete the block type, which should now be allowed.
     $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
-      t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()])
-    );
+    $this->assertSession()->pageTextContains('Are you sure you want to delete the custom block type ' . $type->id() . '?');
     $this->assertSession()->pageTextContains('This action cannot be undone.');
   }
 
diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php
index 11ca3bd98850..b3508a149ca7 100644
--- a/core/modules/book/tests/src/Functional/BookTest.php
+++ b/core/modules/book/tests/src/Functional/BookTest.php
@@ -459,7 +459,7 @@ public function testBookDelete() {
     $nodes = $this->createBook();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet($this->book->toUrl('delete-form'));
-    $this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
+    $this->assertSession()->pageTextContains($this->book->label() . ' is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.');
     // Delete parent, and visit a child page.
     $this->drupalGet($this->book->toUrl('delete-form'));
     $this->submitForm([], 'Delete');
@@ -489,7 +489,7 @@ public function testBookOutline() {
 
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/' . $empty_book->id() . '/outline');
-    $this->assertRaw(t('Book outline'));
+    $this->assertSession()->pageTextContains('Book outline');
     // Verify that the node does not belong to a book.
     $this->assertTrue($this->assertSession()->optionExists('edit-book-bid', 0)->isSelected());
     $this->assertSession()->linkNotExists('Remove from book outline');
@@ -512,9 +512,9 @@ public function testBookOutline() {
 
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/' . $book->id() . '/outline');
-    $this->assertRaw(t('Book outline'));
+    $this->assertSession()->pageTextContains('Book outline');
     $this->clickLink('Remove from book outline');
-    $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
+    $this->assertSession()->pageTextContains('Are you sure you want to remove ' . $book->label() . ' from the book hierarchy?');
 
     // Create a new node and set the book after the node was created.
     $node = $this->drupalCreateNode(['type' => 'book']);
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
index c9702c3ae200..f101ed0a645c 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
@@ -77,7 +77,7 @@ public function testExistingFormat() {
       'editor[editor]' => 'ckeditor',
     ];
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('You must configure the selected text editor.'));
+    $this->assertSession()->pageTextContains('You must configure the selected text editor.');
 
     // Ensure the CKEditor editor returns the expected default settings.
     $expected_default_settings = [
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
index 5596099a8793..44444d089de4 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
@@ -95,7 +95,7 @@ public function testExistingFormat() {
       'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Title\n\n",
     ];
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('Each style must have a unique label.'));
+    $this->assertSession()->pageTextContains('Each style must have a unique label.');
     $editor = Editor::load($this->format);
     $this->assertEquals($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
   }
diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
index be1ded7ba3c1..b197181aaf3a 100644
--- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
@@ -80,9 +80,7 @@ public function testAnonymous() {
     ];
     $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
-      '%name' => $this->adminUser->getAccountName(),
-    ]));
+    $this->assertSession()->pageTextContains('The name you used (' . $this->adminUser->getAccountName() . ') belongs to a registered user.');
 
     // Allow contact info.
     $this->drupalLogin($this->adminUser);
@@ -114,9 +112,7 @@ public function testAnonymous() {
     ];
     $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
-      '%name' => $this->adminUser->getAccountName(),
-    ]));
+    $this->assertSession()->pageTextContains('The name you used (' . $this->adminUser->getAccountName() . ') belongs to a registered user.');
 
     // Require contact info.
     $this->drupalLogin($this->adminUser);
diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
index 6f9a9691bf93..8b8d78d7b3ca 100644
--- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
@@ -239,7 +239,7 @@ public function performCommentOperation($comment, $operation, $approval = FALSE)
 
     if ($operation == 'delete') {
       $this->submitForm([], 'Delete');
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'));
+      $this->assertSession()->pageTextContains('Deleted 1 comment.');
     }
     else {
       $this->assertSession()->pageTextContains('The update has been performed.');
diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
index cca715da3e74..430a098f627e 100644
--- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
@@ -45,7 +45,7 @@ public function testCommentPaging() {
     // Check the first page of the node, and confirm the correct comments are
     // shown.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw(t('next'));
+    $this->assertSession()->pageTextContains('next');
     $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page 1.');
     $this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 1.');
     $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.');
@@ -382,7 +382,7 @@ public function testTwoPagers() {
     // Check the first page of the node, and confirm the correct comments are
     // shown.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw(t('next'));
+    $this->assertSession()->pageTextContains('next');
     $this->assertRaw('Comment 1 on field comment');
     $this->assertRaw('Comment 1 on field comment_2');
     // Navigate to next page of field 1.
diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php
index 91a7130ce1cd..4c58735260f6 100644
--- a/core/modules/comment/tests/src/Functional/CommentTestBase.php
+++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php
@@ -367,7 +367,7 @@ public function performCommentOperation(CommentInterface $comment, $operation, $
 
     if ($operation == 'delete') {
       $this->submitForm([], 'Delete');
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'));
+      $this->assertSession()->pageTextContains('Deleted 1 comment.');
     }
     else {
       $this->assertSession()->pageTextContains('The update has been performed.');
diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
index fa4e876013c2..5aae524c71eb 100644
--- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
@@ -229,13 +229,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('Edit @type @title [%language translation]', [
-          '@type' => $this->entityTypeId,
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("Edit {$this->entityTypeId} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
index a4a72a901833..49a4eddc4dc9 100644
--- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
@@ -161,15 +161,8 @@ public function testCommentTypeDeletion() {
 
     // Attempt to delete the comment type, which should not be allowed.
     $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
-      t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', ['%label' => $type->label()])
-    );
-    $this->assertRaw(
-      t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
-        '%label' => 'foo',
-        '%field' => 'node.foo',
-      ])
-    );
+    $this->assertSession()->pageTextContains($type->label() . ' is used by 1 comment on your site. You can not remove this comment type until you have removed all of the ' . $type->label() . ' comments.');
+    $this->assertSession()->pageTextContains('foo is used by the node.foo field on your site. You can not remove this comment type until you have removed the field.');
     $this->assertSession()->pageTextNotContains('This action cannot be undone.');
 
     // Delete the comment and the field.
@@ -177,9 +170,7 @@ public function testCommentTypeDeletion() {
     $field_storage->delete();
     // Attempt to delete the comment type, which should now be allowed.
     $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
-      t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()])
-    );
+    $this->assertSession()->pageTextContains('Are you sure you want to delete the comment type ' . $type->id() . '?');
     $this->assertSession()->pageTextContains('This action cannot be undone.');
 
     // Test exception thrown when re-using an existing comment type.
@@ -195,7 +186,7 @@ public function testCommentTypeDeletion() {
     $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
     $this->submitForm([], 'Delete');
     $this->assertNull(CommentType::load($type->id()), 'Comment type deleted.');
-    $this->assertRaw(t('The comment type %label has been deleted.', ['%label' => $type->label()]));
+    $this->assertSession()->pageTextContains('The comment type ' . $type->label() . ' has been deleted.');
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
index 0520b2052634..8cd8991917ce 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
@@ -234,9 +234,9 @@ public function testCRUDUI() {
     $label1 = $this->randomMachineName();
     $label2 = $this->randomMachineName();
     $label3 = $this->randomMachineName();
-    $message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $label1]);
-    $message_update = new FormattableMarkup('%label configuration has been updated.', ['%label' => $label2]);
-    $message_delete = new FormattableMarkup('The test configuration %label has been deleted.', ['%label' => $label2]);
+    $message_insert = "$label1 configuration has been created.";
+    $message_update = "$label2 configuration has been updated.";
+    $message_delete = "The test configuration $label2 has been deleted.";
 
     // Create a configuration entity.
     $edit = [
@@ -247,8 +247,8 @@ public function testCRUDUI() {
     $this->submitForm($edit, 'Save');
     $this->assertSession()->addressEquals('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw($message_insert);
-    $this->assertNoRaw($message_update);
+    $this->assertSession()->pageTextContains($message_insert);
+    $this->assertSession()->pageTextNotContains($message_update);
     $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id");
 
     // Update the configuration entity.
@@ -259,8 +259,8 @@ public function testCRUDUI() {
     $this->submitForm($edit, 'Save');
     $this->assertSession()->addressEquals('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw($message_insert);
-    $this->assertRaw($message_update);
+    $this->assertSession()->pageTextNotContains($message_insert);
+    $this->assertSession()->pageTextContains($message_update);
     $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id");
     $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id/delete");
 
@@ -271,8 +271,8 @@ public function testCRUDUI() {
     $this->submitForm([], 'Delete');
     $this->assertSession()->addressEquals('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw($message_update);
-    $this->assertRaw($message_delete);
+    $this->assertSession()->pageTextNotContains($message_update);
+    $this->assertSession()->pageTextContains($message_delete);
     $this->assertSession()->pageTextNotContains($label1);
     $this->assertSession()->linkByHrefNotExists("admin/structure/config_test/manage/$id");
 
@@ -312,8 +312,7 @@ public function testCRUDUI() {
     $this->drupalGet('admin/structure/config_test/add');
     $this->submitForm($edit, 'Save');
     $this->assertSession()->statusCodeEquals(200);
-    $message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $edit['label']]);
-    $this->assertRaw($message_insert);
+    $this->assertSession()->pageTextContains('0 configuration has been created.');
     $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0');
     $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0/delete');
     $this->drupalGet('admin/structure/config_test/manage/0/delete');
diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
index dd89f258307c..5c653b74d3c0 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
@@ -471,8 +471,8 @@ public function testEntityBundleDelete() {
     // and the node type, body field and entity displays are still scheduled for
     // removal.
     $this->submitForm([], 'Import all');
-    $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]);
-    $this->assertRaw($validation_message);
+    $validation_message = "Entities exist of type {$node->getEntityType()->getLabel()} and {$node->getEntityType()->getBundleLabel()} {$node_type->label()}. These entities need to be deleted before importing.";
+    $this->assertSession()->pageTextContains($validation_message);
     $this->assertSession()->pageTextContains('node.type.' . $node_type->id());
     $this->assertSession()->pageTextContains('field.field.node.' . $node_type->id() . '.body');
     $this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.teaser');
@@ -482,7 +482,7 @@ public function testEntityBundleDelete() {
     // Delete the node and try to import again.
     $node->delete();
     $this->submitForm([], 'Import all');
-    $this->assertNoRaw($validation_message);
+    $this->assertSession()->pageTextNotContains($validation_message);
     $this->assertSession()->pageTextContains('There are no configuration changes to import.');
     $this->assertSession()->pageTextNotContains('node.type.' . $node_type->id());
     $this->assertSession()->pageTextNotContains('field.field.node.' . $node_type->id() . '.body');
diff --git a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
index 5a1fd2314e26..8cf1c883c293 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
@@ -60,7 +60,7 @@ public function testImport() {
     $directory = Settings::get('config_sync_directory');
     \Drupal::service('file_system')->chmod($directory, 0555);
     $this->drupalGet('admin/config/development/configuration/full/import');
-    $this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
+    $this->assertSession()->pageTextContains("The directory $directory is not writable.");
     // Ensure submit button for \Drupal\config\Form\ConfigImportForm is
     // disabled.
     $submit_is_disabled = $this->cssSelect('form.config-import-form input[type="submit"]:disabled');
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
index f583f8702d33..780542869620 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
@@ -234,7 +234,7 @@ public function testConfigModuleRequirements() {
       // Ignore failed deletes.
     }
     $this->drupalGet('/admin/reports/status');
-    $this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory]));
+    $this->assertSession()->pageTextContains("The directory $directory does not exist.");
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
index 06d02eba64d9..2a74a11c4ef0 100644
--- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
@@ -77,13 +77,13 @@ public function testImport() {
     $edit['import'] = "id: first\n" . $edit['import'];
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
+    $this->assertSession()->pageTextContains('Are you sure you want to create a new first test configuration?');
     $this->submitForm([], 'Confirm');
     $entity = $storage->load('first');
     $this->assertSame('First', $entity->label());
     $this->assertSame('first', $entity->id());
     $this->assertTrue($entity->status());
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->pageTextContains('The configuration was imported successfully.');
 
     // Attempt an import with an existing ID but missing UUID.
     $this->drupalGet('admin/config/development/configuration/single/import');
@@ -100,9 +100,9 @@ public function testImport() {
     $edit['custom_entity_id'] = 'custom_id';
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
+    $this->assertSession()->pageTextContains('Are you sure you want to create a new custom_id test configuration?');
     $this->submitForm([], 'Confirm');
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->pageTextContains('The configuration was imported successfully.');
 
     // Perform an import with a unique ID and UUID.
     $import = <<<EOD
@@ -120,10 +120,10 @@ public function testImport() {
     $edit['import'] .= "\nuuid: " . $second_uuid;
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+    $this->assertSession()->pageTextContains('Are you sure you want to create a new second test configuration?');
     $this->submitForm([], 'Confirm');
     $entity = $storage->load('second');
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->pageTextContains('The configuration was imported successfully.');
     $this->assertSame('Second', $entity->label());
     $this->assertSame('second', $entity->id());
     $this->assertFalse($entity->status());
@@ -144,10 +144,10 @@ public function testImport() {
     ];
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+    $this->assertSession()->pageTextContains('Are you sure you want to update the second test configuration?');
     $this->submitForm([], 'Confirm');
     $entity = $storage->load('second');
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->pageTextContains('The configuration was imported successfully.');
     $this->assertSame('Second updated', $entity->label());
 
     // Try to perform an update which adds missing dependencies.
@@ -168,7 +168,7 @@ public function testImport() {
     ];
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
+    $this->assertSession()->pageTextContains('Configuration config_test.dynamic.second depends on the does_not_exist module that will not be installed after import.');
 
     // Try to preform an update which would create a PHP object if Yaml parsing
     // not securely set up.
@@ -190,13 +190,10 @@ public function testImport() {
     if (extension_loaded('yaml')) {
       // If the yaml extension is loaded it will work but not create the PHP
       // object.
-      $this->assertRaw(t('Are you sure you want to update the %name @type?', [
-        '%name' => 'second',
-        '@type' => 'test configuration',
-      ]));
+      $this->assertSession()->pageTextContains('Are you sure you want to update the second test configuration?');
       $this->submitForm([], 'Confirm');
       $entity = $storage->load('second');
-      $this->assertRaw(t('The configuration was imported successfully.'));
+      $this->assertSession()->pageTextContains('The configuration was imported successfully.');
       $this->assertIsString($entity->label());
       $this->assertStringContainsString('ObjectSerialization', $entity->label(), 'Label contains serialized object');
     }
@@ -224,7 +221,7 @@ public function testImportSimpleConfiguration() {
     ];
     $this->drupalGet('admin/config/development/configuration/single/import');
     $this->submitForm($edit, 'Import');
-    $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
+    $this->assertSession()->pageTextContains('Are you sure you want to update the ' . $config->getName() . ' simple configuration?');
     $this->submitForm([], 'Confirm');
     $this->drupalGet('');
     $this->assertSession()->pageTextContains('Test simple import');
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
index 5cca0734e0ab..c44ecb251a39 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
@@ -374,7 +374,7 @@ public function doResponsiveImageListTest() {
 
     $this->drupalGet('admin/config/media/responsive-image-style/add');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("Responsive image style {$edit['label']} saved.");
 
     // Get the responsive image style listing.
     $this->drupalGet('admin/config/media/responsive-image-style');
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
index ddf6500921b5..3fe24c72b47e 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
@@ -172,7 +172,7 @@ public function testSiteInformationTranslationUi() {
 
     $this->drupalGet("{$translation_base_url}/fr/add");
     $this->submitForm($edit, 'Save translation');
-    $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
+    $this->assertSession()->pageTextContains('Successfully saved French translation.');
 
     // Check for edit, delete links (and no 'add' link) for French language.
     $this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add");
@@ -274,7 +274,7 @@ public function testSourceValueDuplicateSave() {
       'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
     ];
     $this->submitForm($edit, 'Save translation');
-    $this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French']));
+    $this->assertSession()->pageTextContains('Successfully updated French translation.');
     $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
 
     // Expect only slogan in language specific file.
@@ -417,12 +417,12 @@ public function testContactConfigEntityTranslation() {
       $replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => mb_strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()];
 
       $this->drupalGet("$translation_base_url/$langcode/delete");
-      $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
+      $this->assertSession()->responseContains(t('Are you sure you want to delete the @language translation of %label?', $replacements));
       // Assert link back to list page to cancel delete is present.
       $this->assertSession()->linkByHrefExists($translation_base_url);
 
       $this->submitForm([], 'Delete');
-      $this->assertRaw(t('@language translation of %label was deleted', $replacements));
+      $this->assertSession()->responseContains(t('@language translation of %label was deleted', $replacements));
       $this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/add");
       $this->assertSession()->linkByHrefNotExists("translation_base_url/$langcode/edit");
       $this->assertSession()->linkByHrefNotExists("$translation_base_url/$langcode/delete");
@@ -628,7 +628,7 @@ public function testViewsTranslationUI() {
     ];
     $this->drupalGet("{$translation_base_url}/fr/add");
     $this->submitForm($edit, 'Save translation');
-    $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
+    $this->assertSession()->pageTextContains('Successfully saved French translation.');
 
     // Check for edit, delete links (and no 'add' link) for French language.
     $this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add");
@@ -878,7 +878,7 @@ public function testSingleLanguageUI() {
     // Delete French language
     $this->drupalGet('admin/config/regional/language/delete/fr');
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
+    $this->assertSession()->pageTextContains('The French (fr) language has been removed.');
 
     // Change default language to Tamil.
     $edit = [
@@ -886,12 +886,12 @@ public function testSingleLanguageUI() {
     ];
     $this->drupalGet('admin/config/regional/language');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('Configuration saved.'));
+    $this->assertSession()->pageTextContains('Configuration saved.');
 
     // Delete English language
     $this->drupalGet('admin/config/regional/language/delete/en');
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
+    $this->assertSession()->pageTextContains('The English (en) language has been removed.');
 
     // Visit account setting translation page, this should not
     // throw any notices.
@@ -1156,7 +1156,7 @@ protected function setSiteInformation($site_name, $site_slogan) {
     ];
     $this->drupalGet('admin/config/system/site-information');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('The configuration options have been saved.'));
+    $this->assertSession()->pageTextContains('The configuration options have been saved.');
   }
 
   /**
diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
index 90b1583643a1..b91852918bd0 100644
--- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
@@ -110,7 +110,7 @@ public function testSendPersonalContactMessage() {
     // Verify that the correct watchdog message has been logged.
     $this->drupalGet('/admin/reports/dblog');
     $placeholders = [
-      '@sender_name' => $this->webUser->username,
+      '@sender_name' => $this->webUser->getAccountName(),
       '@sender_email' => $this->webUser->getEmail(),
       '@recipient_name' => $this->contactUser->getAccountName(),
     ];
@@ -142,7 +142,7 @@ public function testPersonalContactAccess() {
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertSession()->statusCodeEquals(200);
     // Check the page title is properly displayed.
-    $this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()]));
+    $this->assertSession()->pageTextContains('Contact ' . $this->adminUser->getDisplayName());
 
     // Test denied access to admin user's own contact form.
     $this->drupalLogout();
@@ -272,7 +272,8 @@ public function testPersonalContactFlood() {
     // Submit contact form one over limit.
     $this->submitPersonalContact($this->contactUser);
     // Normal user should be denied access to flooded contact form.
-    $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]));
+    $interval = \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'));
+    $this->assertSession()->pageTextContains("You cannot send more than 3 messages in {$interval}. Try again later.");
 
     // Test that the admin user can still access the contact form even though
     // the flood limit was reached.
diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
index 6f74dd8e6b77..7b98647bfa19 100644
--- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
@@ -150,7 +150,7 @@ public function testSiteWideContact() {
     $invalid_recipients = ['invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'];
     foreach ($invalid_recipients as $invalid_recipient) {
       $this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE);
-      $this->assertRaw(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient]));
+      $this->assertSession()->pageTextContains($invalid_recipient . ' is an invalid email address.');
     }
 
     // Test validation of empty form and recipients fields.
@@ -223,7 +223,7 @@ public function testSiteWideContact() {
     // Try adding a form that already exists.
     $this->addContactForm($name, $label, '', '', FALSE);
     $this->assertSession()->pageTextNotContains("Contact form $label has been added.");
-    $this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
+    $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
 
     $this->drupalLogout();
 
@@ -245,7 +245,7 @@ public function testSiteWideContact() {
     $this->assertSession()->pageTextContains('Your email address field is required.');
 
     $this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
-    $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
+    $this->assertSession()->pageTextContains('The email address invalid is not valid.');
 
     $this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64));
     $this->assertSession()->pageTextContains('Subject field is required.');
@@ -273,7 +273,7 @@ public function testSiteWideContact() {
     }
     // Submit contact form one over limit.
     $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
-    $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')]));
+    $this->assertSession()->pageTextContains('You cannot send more than ' . $this->config('contact.settings')->get('flood.limit') . ' messages in 10 min. Try again later.');
 
     // Test listing controller.
     $this->drupalLogin($admin_user);
@@ -601,7 +601,7 @@ public function deleteContactForms() {
       else {
         $this->drupalGet("admin/structure/contact/manage/{$id}/delete");
         $this->submitForm([], 'Delete');
-        $this->assertRaw(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()]));
+        $this->assertSession()->pageTextContains("The contact form {$contact_form->label()} has been deleted.");
         $this->assertNull(ContactForm::load($id), new FormattableMarkup('Form %contact_form not found', ['%contact_form' => $contact_form->label()]));
       }
     }
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
index 29563e773e82..0e06ddd2540f 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
@@ -128,7 +128,7 @@ public function testContentTranslationContextualLinks() {
     $this->drupalLogin($this->translator);
     $translate_link = 'node/' . $node->id() . '/translations';
     $this->drupalGet($translate_link);
-    $this->assertRaw(t('Translations of %label', ['%label' => $node->label()]));
+    $this->assertSession()->pageTextContains('Translations of ' . $node->label());
   }
 
 }
diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php
index 61484cddb590..1dda6e86bcda 100644
--- a/core/modules/dblog/tests/src/Functional/DbLogTest.php
+++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php
@@ -474,7 +474,7 @@ private function doUser() {
       $link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/'));
       $this->drupalGet($link);
       // Check for full message text on the details page.
-      $this->assertRaw($message);
+      $this->assertSession()->responseContains($message);
     }
     $this->assertNotEmpty($link, 'DBLog event was recorded: [delete user]');
     // Visit random URL (to generate page not found event).
diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php
index ed5e9983530e..7942498b8fc3 100644
--- a/core/modules/field/tests/src/Functional/FormTest.php
+++ b/core/modules/field/tests/src/Functional/FormTest.php
@@ -138,7 +138,7 @@ public function testFieldFormSingle() {
       "{$field_name}[0][value]" => -1,
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $this->field['label']]));
+    $this->assertSession()->pageTextContains("{$this->field['label']} does not accept the value -1.");
     // TODO : check that the correct field is flagged for error.
 
     // Create an entity
@@ -233,7 +233,7 @@ public function testFieldFormSingleRequired() {
     $edit = [];
     $this->drupalGet('entity_test/add');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]));
+    $this->assertSession()->pageTextContains("{$this->field['label']} field is required.");
 
     // Create an entity
     $value = mt_rand(1, 127);
@@ -254,7 +254,7 @@ public function testFieldFormSingleRequired() {
     ];
     $this->drupalGet('entity_test/manage/' . $id . '/edit');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]));
+    $this->assertSession()->pageTextContains("{$this->field['label']} field is required.");
   }
 
   public function testFieldFormUnlimited() {
@@ -465,7 +465,7 @@ public function testFieldFormMultipleWidget() {
     // Submit the form with more values than the field accepts.
     $edit = [$field_name => '1, 2, 3, 4, 5'];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw('this field cannot hold more than 4 values');
+    $this->assertSession()->pageTextContains('this field cannot hold more than 4 values');
     // Check that the field values were not submitted.
     $this->assertFieldValues($entity_init, $field_name, [1, 2, 3]);
 
diff --git a/core/modules/field/tests/src/Functional/NestedFormTest.php b/core/modules/field/tests/src/Functional/NestedFormTest.php
index f949979947ad..4dd8993d5cbe 100644
--- a/core/modules/field/tests/src/Functional/NestedFormTest.php
+++ b/core/modules/field/tests/src/Functional/NestedFormTest.php
@@ -129,7 +129,7 @@ public function testNestedFieldForm() {
     ];
     $this->drupalGet('test-entity/nested/1/2');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']));
+    $this->assertSession()->pageTextContains("Unlimited field does not accept the value -1.");
     // Entity 1: check that the error was flagged on the correct element.
     $error_field = $this->assertSession()->fieldExists('edit-field-unlimited-1-value');
     $this->assertTrue($error_field->hasClass('error'));
@@ -138,7 +138,7 @@ public function testNestedFieldForm() {
     ];
     $this->drupalGet('test-entity/nested/1/2');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']));
+    $this->assertSession()->pageTextContains("Unlimited field does not accept the value -1.");
     // Entity 2: check that the error was flagged on the correct element.
     $error_field = $this->assertSession()->fieldExists('edit-entity-2-field-unlimited-1-value');
     $this->assertTrue($error_field->hasClass('error'));
diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
index 667a587a9dea..576510d9c67f 100644
--- a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
+++ b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
@@ -104,7 +104,7 @@ public function testNumberDecimalField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->submitForm($edit, 'Save');
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
+      $this->assertSession()->pageTextContains("{$field_name} must be a number.");
     }
 
     // Try to create entries with minus sign not in the first position.
@@ -122,7 +122,7 @@ public function testNumberDecimalField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->submitForm($edit, 'Save');
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
+      $this->assertSession()->pageTextContains("{$field_name} must be a number.");
     }
   }
 
@@ -209,7 +209,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => $minimum - 1,
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%name must be higher than or equal to %minimum.', ['%name' => $field_name, '%minimum' => $minimum]));
+    $this->assertSession()->pageTextContains("{$field_name} must be higher than or equal to {$minimum}.");
 
     // Try to set a decimal value
     $this->drupalGet('entity_test/add');
@@ -217,7 +217,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => 1.5,
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%name is not a valid number.', ['%name' => $field_name]));
+    $this->assertSession()->pageTextContains("{$field_name} is not a valid number.");
 
     // Try to set a value above the maximum value
     $this->drupalGet('entity_test/add');
@@ -225,7 +225,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => $maximum + 1,
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%name must be lower than or equal to %maximum.', ['%name' => $field_name, '%maximum' => $maximum]));
+    $this->assertSession()->pageTextContains("{$field_name} must be lower than or equal to {$maximum}.");
 
     // Try to set a wrong integer value.
     $this->drupalGet('entity_test/add');
@@ -233,7 +233,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => '20-40',
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
+    $this->assertSession()->pageTextContains("{$field_name} must be a number.");
 
     // Test with valid entries.
     $valid_entries = [
@@ -352,7 +352,7 @@ public function testNumberFloatField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->submitForm($edit, 'Save');
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
+      $this->assertSession()->pageTextContains("{$field_name} must be a number.");
     }
 
     // Try to create entries with minus sign not in the first position.
@@ -370,7 +370,7 @@ public function testNumberFloatField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->submitForm($edit, 'Save');
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
+      $this->assertSession()->pageTextContains("{$field_name} must be a number.");
     }
   }
 
@@ -437,9 +437,9 @@ public function assertSetMinimumValue($field, $minimum_value) {
     $this->drupalGet($field_configuration_url);
     $this->submitForm($edit, 'Save settings');
     // Check if an error message is shown.
-    $this->assertNoRaw(t('%name is not a valid number.', ['%name' => t('Minimum')]));
+    $this->assertSession()->pageTextNotContains("Minimum is not a valid number.");
     // Check if a success message is shown.
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
+    $this->assertSession()->pageTextContains("Saved {$field->getLabel()} configuration.");
     // Check if the minimum value was actually set.
     $this->drupalGet($field_configuration_url);
     $this->assertSession()->fieldValueEquals('edit-settings-min', $minimum_value);
diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
index d49bdfb1e126..155190988b5d 100644
--- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
+++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
@@ -77,7 +77,7 @@ public function testEntityViewModeUI() {
       'label' => $this->randomString(),
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("Saved the {$edit['label']} view mode.");
 
     // Test editing the view mode.
     $this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
@@ -92,9 +92,9 @@ public function testEntityViewModeUI() {
 
     // Test deleting the view mode.
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the view mode %label?', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the view mode {$edit['label']}?");
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The view mode %label has been deleted.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("The view mode {$edit['label']} has been deleted.");
   }
 
   /**
@@ -131,7 +131,7 @@ public function testEntityFormModeUI() {
       'label' => $this->randomString(),
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Saved the %label form mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("Saved the {$edit['label']} form mode.");
 
     // Test editing the form mode.
     $this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
@@ -146,9 +146,9 @@ public function testEntityFormModeUI() {
 
     // Test deleting the form mode.
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the form mode %label?', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the form mode {$edit['label']}?");
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
+    $this->assertSession()->pageTextContains("The form mode {$edit['label']} has been deleted.");
   }
 
   /**
diff --git a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
index b64ca43fb769..d0cbe7fba862 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
@@ -211,7 +211,8 @@ public function testNoFieldsDisplayOverview() {
     ])->save();
 
     $this->drupalGet('admin/structure/types/manage/no_fields/display');
-    $this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString()]));
+    $this->assertSession()->pageTextContains("There are no fields yet added. You can add new fields on the Manage fields page.");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString());
   }
 
   /**
diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
index f3828b8fb25f..b99e51f25f72 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
@@ -255,7 +255,7 @@ public function updateField() {
   public function addExistingField() {
     // Check "Re-use existing field" appears.
     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
-    $this->assertRaw(t('Re-use an existing field'));
+    $this->assertSession()->pageTextContains('Re-use an existing field');
 
     // Check that fields of other entity types (here, the 'comment_body' field)
     // do not show up in the "Re-use existing field" list.
@@ -317,7 +317,7 @@ public function cardinalitySettings() {
     ];
     $this->drupalGet($field_edit_path);
     $this->submitForm($edit, 'Save field settings');
-    $this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 2]));
+    $this->assertSession()->pageTextContains("There is 1 entity with 2 or more values in this field.");
 
     // Create a second entity with three values.
     $edit = ['title[0][value]' => 'Cardinality 3', 'body[0][value]' => 'Body 1', 'body[1][value]' => 'Body 2', 'body[2][value]' => 'Body 3'];
@@ -343,7 +343,7 @@ public function cardinalitySettings() {
     ];
     $this->drupalGet($field_edit_path);
     $this->submitForm($edit, 'Save field settings');
-    $this->assertRaw(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 2]));
+    $this->assertSession()->pageTextContains("There are 2 entities with 2 or more values in this field.");
 
     $edit = [
       'cardinality' => 'number',
@@ -351,7 +351,7 @@ public function cardinalitySettings() {
     ];
     $this->drupalGet($field_edit_path);
     $this->submitForm($edit, 'Save field settings');
-    $this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 3]));
+    $this->assertSession()->pageTextContains("There is 1 entity with 3 or more values in this field.");
 
     $edit = [
       'cardinality' => 'number',
@@ -389,14 +389,14 @@ public function cardinalitySettings() {
     ];
     $this->drupalGet($field_edit_path);
     $this->submitForm($edit, 'Save field settings');
-    $this->assertRaw(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 3]));
+    $this->assertSession()->pageTextContains("There are 2 entities with 3 or more values in this field.");
     $edit = [
       'cardinality' => 'number',
       'cardinality_number' => 3,
     ];
     $this->drupalGet($field_edit_path);
     $this->submitForm($edit, 'Save field settings');
-    $this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 4]));
+    $this->assertSession()->pageTextContains("There is 1 entity with 4 or more values in this field.");
     $edit = [
       'cardinality' => 'number',
       'cardinality_number' => 4,
@@ -432,7 +432,7 @@ protected function addPersistentFieldStorage() {
     }
     // Check "Re-use existing field" appears.
     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
-    $this->assertRaw(t('Re-use an existing field'));
+    $this->assertSession()->pageTextContains("Re-use an existing field");
 
     // Ensure that we test with a label that contains HTML.
     $label = $this->randomString(4) . '<br/>' . $this->randomString(4);
diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
index 9c69705e7317..bd7f0739456f 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
@@ -48,17 +48,17 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
       $this->drupalGet($bundle_path);
     }
     $this->submitForm($initial_edit, 'Save and continue');
-    $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("These settings apply to the $label field everywhere it is used.");
     // Test Breadcrumbs.
     $this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
 
     // Second step: 'Storage settings' form.
     $this->submitForm($storage_edit, 'Save field settings');
-    $this->assertRaw(t('Updated field %label field settings.', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("Updated field $label field settings.");
 
     // Third step: 'Field settings' form.
     $this->submitForm($field_edit, 'Save settings');
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("Saved $label configuration.");
 
     // Check that the field appears in the overview form.
     $xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
@@ -99,7 +99,7 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
 
     // Second step: 'Field settings' form.
     $this->submitForm($field_edit, 'Save settings');
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("Saved $label configuration.");
 
     // Check that the field appears in the overview form.
     $xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
@@ -123,14 +123,14 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
   public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) {
     // Display confirmation form.
     $this->drupalGet("$bundle_path/fields/$field_name/delete");
-    $this->assertRaw(t('Are you sure you want to delete the field %label', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the field $label");
 
     // Test Breadcrumbs.
     $this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
 
     // Submit confirmation form.
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label]));
+    $this->assertSession()->pageTextContains("The field $label has been deleted from the $bundle_label content type.");
 
     // Check that the field does not appear in the overview form.
     $xpath = $this->assertSession()->buildXPathQuery('//table[@id="field-overview"]//span[@class="label-field" and text()= :label]', [
diff --git a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
index 97884b6a8b7d..12f0887391c9 100644
--- a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
@@ -37,7 +37,7 @@ public function testRequired() {
     $edit['title[0][value]'] = $this->randomMachineName();
     $this->drupalGet('node/add/' . $type_name);
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]));
+    $this->assertSession()->pageTextContains("{$field->getLabel()} field is required.");
 
     // Create a new node with the uploaded file.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@@ -59,7 +59,7 @@ public function testRequired() {
     $edit['title[0][value]'] = $this->randomMachineName();
     $this->drupalGet('node/add/' . $type_name);
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]));
+    $this->assertSession()->pageTextContains("{$field->getLabel()} field is required.");
 
     // Create a new node with the uploaded file into the multivalue field.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@@ -105,8 +105,9 @@ public function testFileMaxSize() {
 
       // Check that uploading the large file fails (1M limit).
       $this->uploadNodeFile($large_file, $field_name, $type_name);
-      $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)]);
-      $this->assertRaw($error_message);
+      $filesize = format_size($large_file->getSize());
+      $maxsize = format_size($file_limit);
+      $this->assertSession()->pageTextContains("The file is {$filesize} exceeding the maximum file size of {$maxsize}.");
     }
 
     // Turn off the max filesize.
@@ -149,8 +150,7 @@ public function testFileExtension() {
 
     // Check that the file with the wrong extension cannot be uploaded.
     $this->uploadNodeFile($test_file, $field_name, $type_name);
-    $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
-    $this->assertRaw($error_message);
+    $this->assertSession()->pageTextContains("Only files with the following extensions are allowed: txt.");
 
     // Enable extension checking for text and image files.
     $this->updateFileField($field_name, $type_name, ['file_extensions' => "txt $test_file_extension"]);
diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
index fb9285ed0212..4f3e40ac08d1 100644
--- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
@@ -377,13 +377,12 @@ public function testWidgetValidation() {
     $edit[$name] = \Drupal::service('file_system')->realpath($test_file_image->getFileUri());
     $this->submitForm($edit, 'Upload');
 
-    $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
-    $this->assertRaw($error_message);
+    $this->assertSession()->pageTextContains("Only files with the following extensions are allowed: txt.");
 
     // Upload file with correct extension, check that error message is removed.
     $edit[$name] = \Drupal::service('file_system')->realpath($test_file_text->getFileUri());
     $this->submitForm($edit, 'Upload');
-    $this->assertNoRaw($error_message);
+    $this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed: txt.");
   }
 
   /**
diff --git a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
index 91390dc165fa..c23d199c3a6e 100644
--- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
+++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
@@ -40,7 +40,7 @@ public function testManagedFile() {
           // Submit without a file.
           $this->drupalGet($path);
           $this->submitForm([], 'Save');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [])]));
+          $this->assertSession()->pageTextContains("The file ids are .");
 
           // Submit with a file, but with an invalid form token. Ensure the file
           // was not saved.
@@ -63,12 +63,12 @@ public function testManagedFile() {
           $this->submitForm($edit, 'Save');
           $last_fid = $this->getLastFileId();
           $this->assertGreaterThan($last_fid_prior, $last_fid, 'New file got saved.');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
+          $this->assertSession()->pageTextContains("The file ids are $last_fid.");
 
           // Submit no new input, but with a default file.
           $this->drupalGet($path . '/' . $last_fid);
           $this->submitForm([], 'Save');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
+          $this->assertSession()->pageTextContains("The file ids are $last_fid.");
 
           // Upload, then Submit.
           $last_fid_prior = $this->getLastFileId();
@@ -78,7 +78,7 @@ public function testManagedFile() {
           $last_fid = $this->getLastFileId();
           $this->assertGreaterThan($last_fid_prior, $last_fid, 'New file got uploaded.');
           $this->submitForm([], 'Save');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
+          $this->assertSession()->pageTextContains("The file ids are $last_fid.");
 
           // Remove, then Submit.
           $remove_button_title = $multiple ? 'Remove selected' : 'Remove';
@@ -90,7 +90,7 @@ public function testManagedFile() {
           $this->drupalGet($path . '/' . $last_fid);
           $this->submitForm($remove_edit, $remove_button_title);
           $this->submitForm([], 'Save');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']));
+          $this->assertSession()->pageTextContains("The file ids are .");
 
           // Upload, then Remove, then Submit.
           $this->drupalGet($path);
@@ -104,7 +104,7 @@ public function testManagedFile() {
           $this->submitForm($remove_edit, $remove_button_title);
 
           $this->submitForm([], 'Save');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']));
+          $this->assertSession()->pageTextContains("The file ids are .");
         }
       }
     }
@@ -129,7 +129,7 @@ public function testManagedFile() {
     // Save the entire form.
     $this->submitForm([], 'Save');
     // Check that two files are saved into a single multiple file element.
-    $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', $fid_list)]));
+    $this->assertSession()->pageTextContains("The file ids are " . implode(',', $fid_list) . ".");
 
     // Delete only the first file.
     $edit = [
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index 82646348e6c5..6f101f21a891 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -91,7 +91,7 @@ protected function setUp(): void {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called then clean out the hook
     // counters.
@@ -125,7 +125,7 @@ public function testNormal() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')
       ->accessCheck(FALSE)
       ->aggregate('fid', 'max')
@@ -155,7 +155,7 @@ public function testNormal() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
   }
 
@@ -180,7 +180,7 @@ public function testHandleExtension() {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -199,8 +199,8 @@ public function testHandleExtension() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('Only files with the following extensions are allowed:'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('Only files with the following extensions are allowed:');
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -217,8 +217,8 @@ public function testHandleExtension() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('Only files with the following extensions are allowed:'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('Only files with the following extensions are allowed:');
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -244,8 +244,8 @@ public function testHandleDangerousFile() {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
-    $this->assertRaw(t('File MIME type is text/plain.'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('File MIME type is text/plain.');
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -259,9 +259,9 @@ public function testHandleDangerousFile() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$this->phpfile->filename}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -316,9 +316,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$munged_filename}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -340,9 +340,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$munged_filename}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -360,9 +360,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -380,8 +380,8 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -400,7 +400,7 @@ public function testExistingRename() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -419,7 +419,7 @@ public function testExistingReplace() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -438,7 +438,7 @@ public function testExistingError() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the no hooks were called while failing.
     $this->assertFileHooksCalled([]);
@@ -450,7 +450,7 @@ public function testExistingError() {
   public function testNoUpload() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm([], 'Submit');
-    $this->assertNoRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextNotContains("Epic upload FAIL!");
   }
 
   /**
@@ -473,16 +473,16 @@ public function testDrupalMovingUploadedFileError() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('File upload error. Could not move uploaded file.'));
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains('File upload error. Could not move uploaded file.');
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Uploading failed. Now check the log.
     $this->drupalGet('admin/reports/dblog');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
-      '@file' => $this->image->getFilename(),
-      '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
-    ]));
+    // The full log message is in the title attribute of the link, so we cannot
+    // use ::pageTextContains() here.
+    $destination = 'temporary://' . $test_directory . '/' . $this->image->getFilename();
+    $this->assertSession()->responseContains("Upload error. Could not move uploaded file {$this->image->getFilename()} to destination {$destination}.");
   }
 
   /**
@@ -500,7 +500,7 @@ public function testErrorMessagesAreNotChanged() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
@@ -517,7 +517,7 @@ public function testErrorMessagesAreNotChanged() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
@@ -532,7 +532,7 @@ public function testErrorMessagesAreNotChanged() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Ensure the error message is not present and the counts before and after
     // calling _file_save_upload_from_form() are correct.
@@ -565,7 +565,7 @@ public function testCombinedErrorMessages() {
     $files['files']['file_test_upload'][1] = $file_system->realpath($textfile->uri);
     $client->request($form->getMethod(), $form->getUri(), $edit, $files);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Search for combined error message followed by a formatted list of messages.
     $this->assertSession()->responseContains('One or more files could not be uploaded.<div class="item-list">');
@@ -586,7 +586,7 @@ public function testUploadFieldIsHighlighted() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
     $this->assertCount(1, $this->cssSelect('input[name="files[file_test_upload][]"].error'), 'File upload field has error.');
   }
 
diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php
index 4b9af9dccd14..f37c2d9bd622 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php
@@ -87,7 +87,7 @@ protected function setUp(): void {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     // Check that the success message is present.
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called then clean out the hook
     // counters.
@@ -119,7 +119,7 @@ public function testNormal() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')
       ->accessCheck(FALSE)
       ->aggregate('fid', 'max')
@@ -149,7 +149,7 @@ public function testNormal() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
   }
 
@@ -180,8 +180,7 @@ public function testDuplicate() {
     $this->submitForm($edit, 'Submit');
     // Received a 200 response for posted test file.
     $this->assertSession()->statusCodeEquals(200);
-    $message = t('The file %file already exists. Enter a unique file URI.', ['%file' => $file1->getFileUri()]);
-    $this->assertRaw($message);
+    $this->assertSession()->pageTextContains("The file {$file1->getFileUri()} already exists. Enter a unique file URI.");
     $max_fid_before_duplicate = $max_fid_after;
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')
       ->accessCheck(FALSE)
@@ -209,7 +208,7 @@ public function testHandleExtension() {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -228,8 +227,8 @@ public function testHandleExtension() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('Only files with the following extensions are allowed:'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed:");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -246,8 +245,8 @@ public function testHandleExtension() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('Only files with the following extensions are allowed:'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed:");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -268,8 +267,8 @@ public function testHandleExtension() {
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
     $this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
-    $this->assertRaw(t('File MIME type is text/plain.'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('File MIME type is text/plain.');
+    $this->assertSession()->pageTextContains("You WIN!");
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
   }
@@ -293,8 +292,8 @@ public function testHandleDangerousFile() {
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
     $this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
-    $this->assertRaw(t('File MIME type is text/plain.'));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('File MIME type is text/plain.');
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -308,9 +307,9 @@ public function testHandleDangerousFile() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
     $this->assertSession()->pageTextContains('File name is php-2.php.');
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -325,7 +324,7 @@ public function testHandleDangerousFile() {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -341,7 +340,7 @@ public function testHandleDangerousFile() {
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -448,9 +447,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is $munged_filename");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -469,9 +468,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -489,9 +488,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -511,9 +510,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename', ['@filename' => 'image-test.png_.php_.png']));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is image-test.png_.php_.png");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -530,9 +529,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename.', ['@filename' => 'image-test.png_.php__0.png']));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is image-test.png_.php__0.png");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -551,9 +550,9 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('File name is @filename.', ['@filename' => 'image-test.png_.cgi_.png_.txt']));
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("File name is image-test.png_.cgi_.png_.txt");
+    $this->assertSession()->pageTextContains("You WIN!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -571,8 +570,8 @@ public function testHandleFileMunge() {
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertNoRaw(t('For security reasons, your upload has been renamed'));
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -589,7 +588,7 @@ public function testExistingRename() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $this->assertSession()->pageTextContains('File name is image-test_0.png.');
 
     // Check that the correct hooks were called.
@@ -607,7 +606,7 @@ public function testExistingReplace() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
     $this->assertSession()->pageTextContains('File name is image-test.png.');
 
     // Check that the correct hooks were called.
@@ -625,7 +624,7 @@ public function testExistingError() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Check that the no hooks were called while failing.
     $this->assertFileHooksCalled([]);
@@ -637,7 +636,7 @@ public function testExistingError() {
   public function testNoUpload() {
     $this->drupalGet('file-test/upload');
     $this->submitForm([], 'Submit');
-    $this->assertNoRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextNotContains("Epic upload FAIL!");
   }
 
   /**
@@ -660,16 +659,16 @@ public function testDrupalMovingUploadedFileError() {
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('File upload error. Could not move uploaded file.'));
-    $this->assertRaw(t('Epic upload FAIL!'));
+    $this->assertSession()->pageTextContains('File upload error. Could not move uploaded file.');
+    $this->assertSession()->pageTextContains("Epic upload FAIL!");
 
     // Uploading failed. Now check the log.
     $this->drupalGet('admin/reports/dblog');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
-      '@file' => $this->image->getFilename(),
-      '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
-    ]));
+    // The full log message is in the title attribute of the link, so we cannot
+    // use ::pageTextContains() here.
+    $destination = 'temporary://' . $test_directory . '/' . $this->image->getFilename();
+    $this->assertSession()->responseContains("Upload error. Could not move uploaded file {$this->image->getFilename()} to destination {$destination}.");
   }
 
   /**
diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
index a5fb67d265e0..b8b44779bb3f 100644
--- a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
@@ -210,13 +210,7 @@ public function testUploadingMoreFilesThenAllowed() {
     $multiple_field = $this->getSession()->getPage()->findField('files[test_file_field_1_0][]');
     $multiple_field->setValue(implode("\n", $remote_paths));
     $this->assertSession()->assertWaitOnAjaxRequest();
-    $args = [
-      '%field' => $field_name,
-      '@max' => $cardinality,
-      '@count' => 3,
-      '%list' => 'text-2.txt',
-    ];
-    $this->assertRaw(t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args));
+    $this->assertSession()->pageTextContains("Field {$field_name} can only hold {$cardinality} values but there were 3 uploaded. The following files have been omitted as a result: text-2.txt.");
   }
 
   /**
diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
index 2643881ab0f9..d5bf2d8acad4 100644
--- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
@@ -188,9 +188,7 @@ public function testFormatAdmin() {
     ];
     $this->drupalGet('admin/config/content/formats/add');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('Text format names must be unique. A format named %name already exists.', [
-      '%name' => $name,
-    ]));
+    $this->assertSession()->pageTextContains("Text format names must be unique. A format named $name already exists.");
   }
 
   /**
@@ -268,7 +266,7 @@ public function testFilterAdmin() {
     $this->drupalGet('admin/config/content/formats/add');
     $this->submitForm($edit, 'Save configuration');
     $this->assertSession()->addressEquals('admin/config/content/formats');
-    $this->assertRaw(t('Added text format %format.', ['%format' => $edit['name']]));
+    $this->assertSession()->pageTextContains("Added text format {$edit['name']}.");
 
     filter_formats_reset();
     $format = FilterFormat::load($edit['format']);
@@ -286,7 +284,7 @@ public function testFilterAdmin() {
     $this->drupalGet('admin/config/content/formats/manage/' . $format->id() . '/disable');
     $this->submitForm([], 'Disable');
     $this->assertSession()->addressEquals('admin/config/content/formats');
-    $this->assertRaw(t('Disabled text format %format.', ['%format' => $edit['name']]));
+    $this->assertSession()->pageTextContains("Disabled text format {$edit['name']}.");
     \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([RoleInterface::AUTHENTICATED_ID]);
     $role = Role::load(RoleInterface::AUTHENTICATED_ID);
     $this->assertFalse($role->hasPermission($format->getPermissionName()), 'The filter permission has been removed from the authenticated role');
@@ -299,7 +297,7 @@ public function testFilterAdmin() {
     $this->drupalGet('admin/config/content/formats/manage/' . $full);
     $this->submitForm($edit, 'Save configuration');
     $this->assertSession()->addressEquals('admin/config/content/formats/manage/' . $full);
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]));
+    $this->assertSession()->pageTextContains("The text format {$format->label()} has been updated.");
 
     // Switch user.
     $this->drupalLogin($this->webUser);
@@ -365,7 +363,7 @@ public function testFilterAdmin() {
     $this->drupalGet('admin/config/content/formats/manage/' . $full);
     $this->submitForm($edit, 'Save configuration');
     $this->assertSession()->addressEquals('admin/config/content/formats/manage/' . $full);
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]));
+    $this->assertSession()->pageTextContains("The text format {$format->label()} has been updated.");
     $this->drupalGet('admin/config/content/formats/manage/' . $full);
     $this->assertSession()->fieldValueEquals('roles[' . RoleInterface::AUTHENTICATED_ID . ']', $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']']);
 
@@ -391,7 +389,7 @@ public function testUrlFilterAdmin() {
     ];
     $this->drupalGet('admin/config/content/formats/manage/basic_html');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertNoRaw(t('The text format %format has been updated.', ['%format' => 'Basic HTML']));
+    $this->assertSession()->pageTextNotContains("The text format Basic HTML has been updated.");
   }
 
   /**
diff --git a/core/modules/filter/tests/src/Functional/FilterHooksTest.php b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
index 3b4b5bbd4ed9..c8e33190b867 100644
--- a/core/modules/filter/tests/src/Functional/FilterHooksTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
@@ -51,7 +51,7 @@ public function testFilterHooks() {
     $edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 1;
     $this->drupalGet('admin/config/content/formats/add');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('Added text format %format.', ['%format' => $name]));
+    $this->assertSession()->pageTextContains("Added text format {$name}.");
     $this->assertSession()->pageTextContains('hook_filter_format_insert invoked.');
 
     $format_id = $edit['format'];
@@ -61,7 +61,7 @@ public function testFilterHooks() {
     $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
     $this->drupalGet('admin/config/content/formats/manage/' . $format_id);
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $name]));
+    $this->assertSession()->pageTextContains("The text format {$name} has been updated.");
     $this->assertSession()->pageTextContains('hook_filter_format_update invoked.');
 
     // Use the format created.
@@ -77,7 +77,7 @@ public function testFilterHooks() {
     // Disable the text format.
     $this->drupalGet('admin/config/content/formats/manage/' . $format_id . '/disable');
     $this->submitForm([], 'Disable');
-    $this->assertRaw(t('Disabled text format %format.', ['%format' => $name]));
+    $this->assertSession()->pageTextContains("Disabled text format {$name}.");
     $this->assertSession()->pageTextContains('hook_filter_format_disable invoked.');
   }
 
diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php
index 9a1847a2fee3..68c380efda51 100644
--- a/core/modules/forum/tests/src/Functional/ForumTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumTest.php
@@ -346,7 +346,7 @@ private function doAdminTests($user) {
     // Save forum overview.
     $this->drupalGet('admin/structure/forum/');
     $this->submitForm([], 'Save');
-    $this->assertRaw(t('The configuration options have been saved.'));
+    $this->assertSession()->pageTextContains('The configuration options have been saved.');
     // Delete this second forum.
     $this->deleteForum($delete_forum['tid']);
     // Create forum at the top (root) level.
@@ -403,7 +403,7 @@ public function editForumVocabulary() {
     $this->drupalGet('admin/structure/taxonomy/manage/' . $original_vocabulary->id());
     $this->submitForm($edit, 'Save');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Updated vocabulary %name.', ['%name' => $edit['name']]));
+    $this->assertSession()->pageTextContains("Updated vocabulary {$edit['name']}.");
 
     // Grab the newly edited vocabulary.
     $current_vocabulary = Vocabulary::load($vid);
@@ -586,12 +586,12 @@ public function createForumTopic($forum, $container = FALSE) {
     $type = t('Forum topic');
     if ($container) {
       $this->assertSession()->pageTextNotContains("$type $title has been created.");
-      $this->assertRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]));
+      $this->assertSession()->pageTextContains("The item {$forum['name']} is a forum container, not a forum.");
       return;
     }
     else {
       $this->assertSession()->pageTextContains($type . ' ' . $title . ' has been created.');
-      $this->assertNoRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]));
+      $this->assertSession()->pageTextNotContains("The item {$forum['name']} is a forum container, not a forum.");
 
       // Verify that the creation message contains a link to a node.
       $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]');
@@ -688,7 +688,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) {
       $this->drupalGet('node/' . $node->id() . '/delete');
       $this->submitForm([], 'Delete');
       $this->assertSession()->statusCodeEquals($response);
-      $this->assertRaw(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]));
+      $this->assertSession()->pageTextContains("Forum topic {$edit['title[0][value]']} has been deleted.");
     }
   }
 
diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php
index 9e0e14c96ad2..0c6443ea85ed 100644
--- a/core/modules/help/tests/src/Functional/HelpTest.php
+++ b/core/modules/help/tests/src/Functional/HelpTest.php
@@ -73,7 +73,7 @@ public function testHelp() {
     // Verify that introductory help text exists, goes for 100% module coverage.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/help');
-    $this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
+    $this->assertSession()->responseContains('For more information, refer to the help listed on this page or to the <a href="https://www.drupal.org/documentation">online documentation</a> and <a href="https://www.drupal.org/support">support</a> pages at <a href="https://www.drupal.org">drupal.org</a>.');
 
     // Verify that hook_help() section title and description appear.
     $this->assertSession()->responseContains('<h2>Module overviews</h2>');
@@ -92,7 +92,7 @@ public function testHelp() {
     // Ensure a module which does not provide a module overview page is handled
     // correctly.
     $this->clickLink(\Drupal::moduleHandler()->getName('help_test'));
-    $this->assertRaw(t('No help is available for module %module.', ['%module' => \Drupal::moduleHandler()->getName('help_test')]));
+    $this->assertSession()->pageTextContains('No help is available for module ' . \Drupal::moduleHandler()->getName('help_test'));
 
     // Verify that the order of topics is alphabetical by displayed module
     // name, by checking the order of some modules, including some that would
diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
index 32ea357ba955..cb597b7ff183 100644
--- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
@@ -68,7 +68,7 @@ public function testNumericStyleName() {
     ];
     $this->drupalGet('admin/config/media/image-styles/add');
     $this->submitForm($edit, 'Create new style');
-    $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
+    $this->assertSession()->pageTextContains("Style {$style_label} was created.");
     $options = image_style_options();
     $this->assertArrayHasKey($style_name, $options);
   }
@@ -120,7 +120,7 @@ public function testStyle() {
     ];
     $this->drupalGet($admin_path . '/add');
     $this->submitForm($edit, 'Create new style');
-    $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
+    $this->assertSession()->pageTextContains("Style {$style_label} was created.");
 
     // Ensure that the expected entity operations are there.
     $this->drupalGet($admin_path);
@@ -257,7 +257,7 @@ public function testStyle() {
     // Confirm that the form submission was successful.
     $this->assertSession()->statusCodeEquals(200);
     $image_crop_effect = $style->getEffect($uuids['image_crop']);
-    $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()]));
+    $this->assertSession()->pageTextContains("The image effect {$image_crop_effect->label()} has been deleted.");
     // Confirm that there is no longer a link to the effect.
     $this->assertSession()->linkByHrefNotExists($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
     // Refresh the image style information and verify that the effect was
@@ -305,9 +305,8 @@ public function testStyle() {
 
     // Confirm that the empty text is correct on the image styles page.
     $this->drupalGet($admin_path);
-    $this->assertRaw(t('There are currently no styles. <a href=":url">Add a new one</a>.', [
-      ':url' => Url::fromRoute('image.style_add')->toString(),
-    ]));
+    $this->assertSession()->pageTextContains("There are currently no styles. Add a new one.");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('image.style_add')->toString());
 
   }
 
@@ -371,8 +370,7 @@ public function testStyleReplacement() {
     ];
     $this->drupalGet($style_path . $new_style_name . '/delete');
     $this->submitForm($edit, 'Delete');
-    $message = t('The image style %name has been deleted.', ['%name' => $new_style_label]);
-    $this->assertRaw($message);
+    $this->assertSession()->pageTextContains("The image style {$new_style_label} has been deleted.");
 
     $replacement_style = ImageStyle::load('thumbnail');
     $this->drupalGet('node/' . $nid);
@@ -523,7 +521,7 @@ public function testImageStyleAccess() {
 
     $this->drupalGet('admin/config/media/image-styles');
     $this->clickLink('Edit');
-    $this->assertRaw(t('Select a new effect'));
+    $this->assertSession()->pageTextContains("Select a new effect");
   }
 
 }
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
index 8e44c55afd9d..185f4f4e56d0 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
@@ -317,14 +317,8 @@ public function testImageFieldSettings() {
     $this->drupalGet('node/' . $nid . '/edit');
     $this->submitForm($edit, 'Save');
     $schema = $field->getFieldStorageDefinition()->getSchema();
-    $this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', [
-      '%max' => $schema['columns']['alt']['length'],
-      '%length' => $test_size,
-    ]));
-    $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', [
-      '%max' => $schema['columns']['title']['length'],
-      '%length' => $test_size,
-    ]));
+    $this->assertSession()->pageTextContains("Alternative text cannot be longer than {$schema['columns']['alt']['length']} characters but is currently {$test_size} characters long.");
+    $this->assertSession()->pageTextContains("Title cannot be longer than {$schema['columns']['title']['length']} characters but is currently {$test_size} characters long.");
 
     // Set cardinality to unlimited and add upload a second image.
     // The image widget is extending on the file widget, but the image field
diff --git a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
index 3f63813f59f8..a78f91980bd7 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
@@ -145,20 +145,16 @@ public function testResolution() {
       }
     }
     $this->uploadNodeImage($image_that_is_too_small, $field_names[0], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
-    $this->assertRaw(t('The image is too small. The minimum dimensions are %dimensions pixels and the image size is %widthx%height pixels.', [
-      '%dimensions' => '50x50',
-      '%width' => $image_that_is_too_small_file->getWidth(),
-      '%height' => $image_that_is_too_small_file->getHeight(),
-      ]));
+    $this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
+    $this->assertSession()->pageTextContains("The image is too small. The minimum dimensions are 50x50 pixels and the image size is {$image_that_is_too_small_file->getWidth()}x{$image_that_is_too_small_file->getHeight()} pixels.");
     $this->uploadNodeImage($image_that_is_too_big, $field_names[0], 'article');
     $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.');
     $this->uploadNodeImage($image_that_is_too_small, $field_names[1], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
+    $this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
     $this->uploadNodeImage($image_that_is_too_big, $field_names[1], 'article');
     $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed width of 100 pixels.');
     $this->uploadNodeImage($image_that_is_too_small, $field_names[2], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
+    $this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
     $this->uploadNodeImage($image_that_is_too_big, $field_names[2], 'article');
     $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed height of 100 pixels.');
   }
diff --git a/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php b/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
index caeef7b675f9..fbdeb95879a9 100644
--- a/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
+++ b/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
@@ -35,8 +35,8 @@ public function testDelete() {
     // Checks that the 'replacement' select element is displayed.
     $this->assertSession()->fieldExists('replacement');
     // Checks that UI messages are correct.
-    $this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
-    $this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
+    $this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
 
     // Delete 'medium' image style but replace it with 'thumbnail'. This style
     // is involved in 'node.page.default' display view and form.
@@ -58,8 +58,8 @@ public function testDelete() {
     // Checks that the 'replacement' select element is displayed.
     $this->assertSession()->fieldExists('replacement');
     // Checks that UI messages are correct.
-    $this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
-    $this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
+    $this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
 
     // Delete 'thumbnail' image style. Provide no replacement.
     $this->submitForm([], 'Delete');
@@ -77,8 +77,8 @@ public function testDelete() {
     // Checks that the 'replacement' select element is displayed.
     $this->assertSession()->fieldExists('replacement');
     // Checks that UI messages are correct.
-    $this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
-    $this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
+    $this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
     // Delete 'wide' image style. Provide no replacement.
     $this->submitForm([], 'Delete');
 
@@ -87,8 +87,8 @@ public function testDelete() {
     // Checks that the 'replacement' select element is not displayed.
     $this->assertSession()->fieldNotExists('replacement');
     // Checks that UI messages are correct.
-    $this->assertNoRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
-    $this->assertRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->pageTextNotContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
+    $this->assertSession()->pageTextContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
   }
 
 }
diff --git a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
index 621910a205cf..e5508896aab4 100644
--- a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
+++ b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
@@ -39,12 +39,12 @@ public function testConfigUsingCurrentLanguage() {
       ->save();
 
     $this->drupalGet('es/admin/language_test/entity_using_current_language/es');
-    $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Spanish']));
-    $this->assertRaw(t('Loaded %label.', ['%label' => 'Español']));
+    $this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Spanish']));
+    $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Español']));
 
     $this->drupalGet('es/admin/language_test/entity_using_original_language/es');
-    $this->assertRaw(t('Loaded %label.', ['%label' => 'Spanish']));
-    $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Español']));
+    $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Spanish']));
+    $this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Español']));
   }
 
 }
diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
index 5894f85c7dd6..e76b229702b4 100644
--- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
@@ -43,21 +43,14 @@ public function testUIBrowserLanguageMappings() {
     // Delete zh-cn language code.
     $browser_langcode = 'zh-cn';
     $this->drupalGet('admin/config/regional/language/detection/browser/delete/' . $browser_langcode);
-    $message = t('Are you sure you want to delete @browser_langcode?', [
-      '@browser_langcode' => $browser_langcode,
-    ]);
-    $this->assertRaw($message);
+    $this->assertSession()->pageTextContains("Are you sure you want to delete {$browser_langcode}?");
 
     // Confirm the delete.
     $edit = [];
     $this->drupalGet('admin/config/regional/language/detection/browser/delete/' . $browser_langcode);
     $this->submitForm($edit, 'Confirm');
 
-    // We need raw here because %browser will add HTML.
-    $t_args = [
-      '%browser' => $browser_langcode,
-    ];
-    $this->assertRaw(t('The mapping for the %browser browser language code has been deleted.', $t_args));
+    $this->assertSession()->pageTextContains("The mapping for the {$browser_langcode} browser language code has been deleted.");
 
     // Check we went back to the browser negotiation mapping overview.
     $this->assertSession()->addressEquals(Url::fromRoute('language.negotiation_browser'));
diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
index 31db7e47af5c..47131bd704c9 100644
--- a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
@@ -125,7 +125,7 @@ public function testLanguageConfiguration() {
     $this->drupalGet('admin/config/regional/language/delete/en');
     $this->submitForm([], 'Delete');
     $this->rebuildContainer();
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
+    $this->assertSession()->pageTextContains("The English (en) language has been removed.");
 
     // Ensure that French language has a weight of 1 after being created through
     // the UI.
diff --git a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
index 43a81b28a22e..dce28a4f06ca 100644
--- a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
@@ -61,12 +61,10 @@ public function testLanguageConfiguration() {
     $this->drupalGet('admin/config/regional/language/add');
     $this->submitForm($edit, 'Add custom language');
 
-    $this->assertRaw(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
-      '%field' => t('Language code'),
-      ':url' => 'http://www.w3.org/International/articles/language-tags/',
-    ]));
-
-    $this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')]));
+    $this->assertSession()->pageTextContains("Language code must be a valid language tag as defined by the W3C.");
+    $this->assertSession()->linkExists("defined by the W3C");
+    $this->assertSession()->linkByHrefExists("http://www.w3.org/International/articles/language-tags/");
+    $this->assertSession()->pageTextContains("Language name cannot contain any markup.");
     $this->assertSession()->addressEquals(Url::fromRoute('language.add'));
 
     // Test adding a custom language with a numeric region code.
@@ -79,10 +77,7 @@ public function testLanguageConfiguration() {
 
     $this->drupalGet('admin/config/regional/language/add');
     $this->submitForm($edit, 'Add custom language');
-    $this->assertRaw(t(
-      'The language %language has been created and can now be used.',
-      ['%language' => $edit['label']]
-    ));
+    $this->assertSession()->pageTextContains("The language {$edit['label']} has been created and can now be used.");
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
 
     // Test validation of existing language values.
@@ -96,19 +91,13 @@ public function testLanguageConfiguration() {
     // Add the language the first time.
     $this->drupalGet('admin/config/regional/language/add');
     $this->submitForm($edit, 'Add custom language');
-    $this->assertRaw(t(
-      'The language %language has been created and can now be used.',
-      ['%language' => $edit['label']]
-    ));
+    $this->assertSession()->pageTextContains("The language {$edit['label']} has been created and can now be used.");
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
 
     // Add the language a second time and confirm that this is not allowed.
     $this->drupalGet('admin/config/regional/language/add');
     $this->submitForm($edit, 'Add custom language');
-    $this->assertRaw(t(
-      'The language %language (%langcode) already exists.',
-      ['%language' => $edit['label'], '%langcode' => $edit['langcode']]
-    ));
+    $this->assertSession()->pageTextContains("The language {$edit['label']} ({$edit['langcode']}) already exists.");
     $this->assertSession()->addressEquals(Url::fromRoute('language.add'));
   }
 
diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php
index d1960c3ddad3..8cc17bfc1597 100644
--- a/core/modules/language/tests/src/Functional/LanguageListTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageListTest.php
@@ -130,9 +130,7 @@ public function testLanguageList() {
     // fields changed.
     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
     $this->submitForm([], 'Delete');
-    // We need raw here because %language and %langcode will add HTML.
-    $t_args = ['%language' => $name, '%langcode' => $langcode];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
+    $this->assertSession()->pageTextContains("The {$name} ({$langcode}) language has been removed.");
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', [], ['language' => $english]));
     // Verify that language is no longer found.
     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
@@ -143,9 +141,7 @@ public function testLanguageList() {
     $this->submitForm([], 'Delete');
     // Make sure the "language_count" state has been updated correctly.
     $this->rebuildContainer();
-    // We need raw here because %language and %langcode will add HTML.
-    $t_args = ['%language' => 'French', '%langcode' => 'fr'];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
+    $this->assertSession()->pageTextContains("The French (fr) language has been removed.");
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
     // Verify that language is no longer found.
     $this->drupalGet('admin/config/regional/language/delete/fr');
@@ -183,9 +179,7 @@ public function testLanguageList() {
 
     $this->drupalGet('admin/config/regional/language/delete/en');
     $this->submitForm([], 'Delete');
-    // We need raw here because %language and %langcode will add HTML.
-    $t_args = ['%language' => 'English', '%langcode' => 'en'];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
+    $this->assertSession()->pageTextContains("The English (en) language has been removed.");
     $this->rebuildContainer();
 
     // Ensure we can't delete a locked language.
diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
index 8725a09503ad..d92af69c7461 100644
--- a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php
@@ -162,8 +162,8 @@ public function testInfoAlterations() {
     $this->assertFalse(isset($negotiation[$test_method_id]), 'The disabled test language negotiation method is not part of the content language negotiation settings.');
 
     // Check that configuration page presents the correct options and settings.
-    $this->assertNoRaw(t('Test language detection'));
-    $this->assertNoRaw(t('This is a test language negotiation method'));
+    $this->assertSession()->pageTextNotContains("Test language detection");
+    $this->assertSession()->pageTextNotContains("This is a test language negotiation method");
   }
 
   /**
diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
index 312c14709a51..2ec2f763cace 100644
--- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
@@ -529,7 +529,7 @@ public function testLanguageDomain() {
     ];
     $this->drupalGet('admin/config/regional/language/detection/url');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => 'Italian']));
+    $this->assertSession()->pageTextContains("The domain for Italian may only contain the domain name, not a trailing slash, protocol and/or port.");
 
     // Build the link we're going to test.
     $link = 'it.example.com' . rtrim(base_path(), '/') . '/admin';
diff --git a/core/modules/locale/tests/src/Functional/LocaleContentTest.php b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
index f1f83b7b4ada..e0026b825c85 100644
--- a/core/modules/locale/tests/src/Functional/LocaleContentTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
@@ -107,7 +107,7 @@ public function testContentTypeLanguageConfiguration() {
     ];
     $this->drupalGet("admin/structure/types/manage/{$type2->id()}");
     $this->submitForm($edit, 'Save content type');
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type2->label()]));
+    $this->assertSession()->pageTextContains("The content type {$type2->label()} has been updated.");
     $this->drupalLogout();
     \Drupal::languageManager()->reset();
 
@@ -196,7 +196,7 @@ public function testContentTypeDirLang() {
     ];
     $this->drupalGet("admin/structure/types/manage/{$type->id()}");
     $this->submitForm($edit, 'Save content type');
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type->label()]));
+    $this->assertSession()->pageTextContains("The content type {$type->label()} has been updated.");
     $this->drupalLogout();
 
     // Log in as web user to add new node.
diff --git a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
index 8b666737d6e7..0db4a607eaf3 100644
--- a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
@@ -85,10 +85,10 @@ public function testStandalonePoFile() {
     ]);
     $this->config('locale.settings');
     // The import should automatically create the corresponding language.
-    $this->assertRaw(t('The language %language has been created.', ['%language' => 'French']));
+    $this->assertSession()->pageTextContains("The language French has been created.");
 
     // The import should have created 8 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 8, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 8 translations were added, 0 translations were updated and 0 translations were removed.");
 
     // This import should have saved plural forms to have 2 variants.
     $locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
@@ -103,10 +103,8 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string and rejected 2.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
-
-    $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
-    $this->assertRaw($skip_message);
+    $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
+    $this->assertSession()->pageTextContains("2 translation strings were skipped because of disallowed or malformed HTML. See the log for details.");
 
     // Repeat the process with a user that can access site reports, and this
     // time the different warnings must contain links to the log.
@@ -117,8 +115,7 @@ public function testStandalonePoFile() {
       'langcode' => 'fr',
     ]);
 
-    $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
-    $this->assertRaw($skip_message);
+    $this->assertSession()->pageTextContains("2 translation strings were skipped because of disallowed or malformed HTML. See the log for details.");
 
     // Check empty files import with a user that cannot access site reports..
     $this->drupalLogin($this->adminUser);
@@ -127,7 +124,7 @@ public function testStandalonePoFile() {
       'langcode' => 'fr',
     ]);
     // The import should have created 0 string and rejected 0.
-    $this->assertRaw(t('One translation file could not be imported. See the log for details.'));
+    $this->assertSession()->pageTextContains("One translation file could not be imported. See the log for details.");
 
     // Repeat the process with a user that can access site reports, and this
     // time the different warnings must contain links to the log.
@@ -137,7 +134,7 @@ public function testStandalonePoFile() {
       'langcode' => 'fr',
     ]);
     // The import should have created 0 string and rejected 0.
-    $this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]));
+    $this->assertSession()->pageTextContains("One translation file could not be imported. See the log for details.");
 
     // Try importing a .po file which doesn't exist.
     $name = $this->randomMachineName(16);
@@ -156,7 +153,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
     // Ensure string wasn't overwritten.
     $search = [
       'string' => 'Montag',
@@ -179,7 +176,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have updated 2 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 2 translations were updated and 0 translations were removed.");
     // Ensure string was overwritten.
     $search = [
       'string' => 'Montag',
@@ -200,7 +197,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 6 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 6, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 6 translations were added, 0 translations were updated and 0 translations were removed.");
 
     // The database should now contain 6 customized strings (two imported
     // strings are not translated).
@@ -220,7 +217,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
     // Ensure string wasn't overwritten.
     $search = [
       'string' => 'januari',
@@ -240,7 +237,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have updated 2 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 2 translations were updated and 0 translations were removed.");
     // Ensure string was overwritten.
     $search = [
       'string' => 'januari',
@@ -279,7 +276,7 @@ public function testEmptyMsgstr() {
       'langcode' => $langcode,
     ]);
 
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
     $this->assertSame('Műveletek', (string) t('Operations', [], ['langcode' => $langcode]), 'String imported and translated.');
 
     // Try importing a .po file.
@@ -287,7 +284,7 @@ public function testEmptyMsgstr() {
       'langcode' => $langcode,
       'overwrite_options[not_customized]' => TRUE,
     ]);
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 0, '%delete' => 1]));
+    $this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 0 translations were updated and 1 translations were removed.");
 
     $str = "Operations";
     $search = [
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
index a5583aba0f93..1c88b11302f6 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
@@ -208,9 +208,7 @@ public function testStringTranslation() {
     // This a confirm form, we do not need any fields changed.
     $this->drupalGet($path);
     $this->submitForm([], 'Delete');
-    // We need raw here because %language and %langcode will add HTML.
-    $t_args = ['%language' => $name, '%langcode' => $langcode];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
+    $this->assertSession()->pageTextContains("The {$name} ({$langcode}) language has been removed.");
     // Reload to remove $name.
     $this->drupalGet($path);
     // Verify that language is no longer found.
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
index cebe7b445b41..2ebba84e2ddb 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
@@ -52,7 +52,8 @@ public function testInterface() {
     $this->assertSession()->pageTextNotContains('Translation update status');
 
     $this->drupalGet('admin/reports/translations');
-    $this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [':add_language' => Url::fromRoute('entity.configurable_language.collection')->toString()]));
+    $this->assertSession()->pageTextContains("No translatable languages available. Add a language first.");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.configurable_language.collection')->toString());
 
     // Add German language.
     $this->addLanguage('de');
@@ -77,7 +78,8 @@ public function testInterface() {
     // Check if updates are available for German.
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->pageTextContains('Translation update status');
-    $this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]));
+    $this->assertSession()->pageTextContains("Updates available for: German. See the Available translation updates page for more information.");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('locale.translate_status')->toString());
     $this->drupalGet('admin/reports/translations');
     $this->assertSession()->pageTextContains('Updates for: Locale test translate');
 
@@ -91,7 +93,8 @@ public function testInterface() {
     // Check if no updates were found.
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->pageTextContains('Translation update status');
-    $this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]));
+    $this->assertSession()->pageTextContains("Missing translations for: German. See the Available translation updates page for more information.");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('locale.translate_status')->toString());
     $this->drupalGet('admin/reports/translations');
     $this->assertSession()->pageTextContains('Missing translations for one project');
     $release_details = new FormattableMarkup('@module (@version). @info', [
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
index ffb6083e8af9..a92a29712d6d 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
@@ -332,8 +332,7 @@ public function testEnableUninstallModule() {
     $this->submitForm($edit, 'Install');
 
     // Check if translations have been imported.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
-      ['%number' => 7, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 7 translations were added, 0 translations were updated and 0 translations were removed.");
     // cSpell:disable-next-line
     $this->assertTranslation('Tuesday', 'Dienstag', 'de');
 
@@ -382,8 +381,7 @@ public function testEnableLanguage() {
     $this->submitForm($edit, 'Add language');
 
     // Check if the right number of translations are added.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
-      ['%number' => 8, '%update' => 0, '%delete' => 0]));
+    $this->assertSession()->pageTextContains("One translation file imported. 8 translations were added, 0 translations were updated and 0 translations were removed.");
     // cSpell:disable-next-line
     $this->assertTranslation('Extraday', 'extra dag', 'nl');
 
diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
index 03fc6e8b106f..87e6c684f2f1 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
@@ -48,7 +48,7 @@ public function testMenuLinkContentDeleteForm() {
 
     $menu_link = MenuLinkContent::load(1);
     $this->drupalGet($menu_link->toUrl('delete-form'));
-    $this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the custom menu link {$menu_link->label()}?");
     $this->assertSession()->linkExists('Cancel');
     // Make sure cancel link points to link edit
     $this->assertSession()->linkByHrefExists($menu_link->toUrl('edit-form')->toString());
@@ -60,7 +60,7 @@ public function testMenuLinkContentDeleteForm() {
     $menu = Menu::load($menu_link->getMenuName());
     $this->assertSession()->linkByHrefExists($menu->toUrl('edit-form')->toString());
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()]));
+    $this->assertSession()->pageTextContains("The menu link {$menu_link->label()} has been deleted.");
   }
 
 }
diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
index 04e1b489e367..0d5dbdac8a53 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
@@ -122,12 +122,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('@title [%language translation]', [
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 496cee07c25d..01efbcf016fe 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -114,7 +114,7 @@ public function testMenuNodeFormWidget() {
     $this->drupalGet('admin/structure/types/manage/page');
     $this->submitForm($edit, 'Save content type');
     $this->assertSession()->pageTextContains('The selected menu link is not under one of the selected menus.');
-    $this->assertNoRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
+    $this->assertSession()->pageTextNotContains("The content type Basic page has been updated.");
 
     // Enable Tools menu as available menu.
     $edit = [
@@ -124,7 +124,7 @@ public function testMenuNodeFormWidget() {
     ];
     $this->drupalGet('admin/structure/types/manage/page');
     $this->submitForm($edit, 'Save content type');
-    $this->assertRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
+    $this->assertSession()->pageTextContains("The content type Basic page has been updated.");
 
     // Test that we can preview a node that will create a menu item.
     $edit = [
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
index b1f89dd2f841..6b5d5123da40 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
@@ -218,11 +218,7 @@ public function addCustomMenu() {
 
     // Verify that using a menu_name that is too long results in a validation
     // message.
-    $this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
-      '@name' => t('Menu name'),
-      '%max' => MenuStorage::MAX_ID_LENGTH,
-      '%length' => mb_strlen($menu_name),
-    ]));
+    $this->assertSession()->pageTextContains("Menu name cannot be longer than " . MenuStorage::MAX_ID_LENGTH . " characters but is currently " . mb_strlen($menu_name) . " characters long.");
 
     // Change the menu_name so it no longer exceeds the maximum length.
     $menu_name = strtolower($this->randomMachineName(MenuStorage::MAX_ID_LENGTH));
@@ -231,13 +227,10 @@ public function addCustomMenu() {
     $this->submitForm($edit, 'Save');
 
     // Verify that no validation error is given for menu_name length.
-    $this->assertNoRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
-      '@name' => t('Menu name'),
-      '%max' => MenuStorage::MAX_ID_LENGTH,
-      '%length' => mb_strlen($menu_name),
-    ]));
+    $this->assertSession()->pageTextNotContains("Menu name cannot be longer than " . MenuStorage::MAX_ID_LENGTH . " characters but is currently " . mb_strlen($menu_name) . " characters long.");
+
     // Verify that the confirmation message is displayed.
-    $this->assertRaw(t('Menu %label has been added.', ['%label' => $label]));
+    $this->assertSession()->pageTextContains("Menu $label has been added.");
     $this->drupalGet('admin/structure/menu');
     $this->assertSession()->pageTextContains($label);
 
@@ -266,7 +259,7 @@ public function deleteCustomMenu() {
     $this->drupalGet("admin/structure/menu/manage/{$menu_name}/delete");
     $this->submitForm([], 'Delete');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu %title has been deleted.', ['%title' => $label]));
+    $this->assertSession()->pageTextContains("The menu $label has been deleted.");
     $this->assertNull(Menu::load($menu_name), 'Custom menu was deleted');
     // Test if all menu links associated with the menu were removed from
     // database.
@@ -303,7 +296,7 @@ public function doMenuTests() {
     $this->assertSession()->addressEquals(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
     // Test the 'Delete' operation.
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', ['%item' => $link_title]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the custom menu link {$link_title}?");
     $this->submitForm([], 'Delete');
     $this->assertSession()->addressEquals(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
 
@@ -681,7 +674,7 @@ public function addInvalidMenuLink() {
       ];
       $this->drupalGet("admin/structure/menu/manage/{$this->menu->id()}/add");
       $this->submitForm($edit, 'Save');
-      $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => $link_path]));
+      $this->assertSession()->pageTextContains("The path '{$link_path}' is inaccessible.");
     }
   }
 
@@ -825,7 +818,7 @@ public function resetMenuLink(MenuLinkInterface $menu_link, $old_weight) {
     $this->drupalGet("admin/structure/menu/link/{$menu_link->getPluginId()}/reset");
     $this->submitForm([], 'Reset');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu link was reset to its default settings.'));
+    $this->assertSession()->pageTextContains('The menu link was reset to its default settings.');
 
     // Verify menu link.
     $instance = \Drupal::service('plugin.manager.menu.link')->createInstance($menu_link->getPluginId());
@@ -846,7 +839,7 @@ public function deleteMenuLink(MenuLinkContent $item) {
     $this->drupalGet("admin/structure/menu/item/{$mlid}/delete");
     $this->submitForm([], 'Delete');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $title]));
+    $this->assertSession()->pageTextContains("The menu link $title has been deleted.");
 
     // Verify deletion.
     $this->drupalGet('');
diff --git a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
index cc595be962f2..fec3e7a84c23 100644
--- a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
@@ -86,7 +86,7 @@ public function testAssignOwnerNodeActionConfiguration() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Make sure that the action was actually deleted.
-    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]));
+    $this->assertSession()->pageTextContains("The action {$new_action_label} has been deleted.");
     $this->drupalGet('admin/config/system/actions');
     $this->assertSession()->statusCodeEquals(200);
     // Check that the label for the node_assign_owner_action action does not
diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
index 3a674a905a7a..1abadcb6fa28 100644
--- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php
+++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
@@ -269,7 +269,7 @@ protected function checkVariousAuthoredByValues(NodeInterface $node, $form_eleme
     ];
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('There are no users matching "%name".', ['%name' => 'invalid-name']));
+    $this->assertSession()->pageTextContains('There are no users matching "invalid-name".');
 
     // Change the authored by field to an empty string, which should assign
     // authorship to the anonymous user (uid 0).
diff --git a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
index ef164d8d6124..fd917dc6b9a3 100644
--- a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
+++ b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
@@ -57,7 +57,7 @@ protected function setUp(): void {
     ];
     $this->drupalGet('admin/structure/types/manage/page');
     $this->submitForm($edit, 'Save content type');
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']));
+    $this->assertSession()->pageTextContains("The content type Basic page has been updated.");
 
     // Make node body translatable.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
index b772ad8dd774..5a79087328cb 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
@@ -150,12 +150,7 @@ public function testRevisions() {
     // Confirm that revisions revert properly.
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert");
     $this->submitForm([], 'Revert');
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.',
-      [
-        '@type' => 'Basic page',
-        '%title' => $nodes[1]->getTitle(),
-        '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
-      ]));
+    $this->assertSession()->pageTextContains("Basic page {$nodes[1]->getTitle()} has been reverted to the revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())}.");
     $node_storage->resetCache([$node->id()]);
     $reverted_node = $node_storage->load($node->id());
     $this->assertSame($nodes[1]->body->value, $reverted_node->body->value, 'Node reverted correctly.');
@@ -178,12 +173,7 @@ public function testRevisions() {
     // Confirm revisions delete properly.
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete");
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
-      [
-        '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
-        '@type' => 'Basic page',
-        '%title' => $nodes[1]->getTitle(),
-      ]));
+    $this->assertSession()->pageTextContains("Revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())} of Basic page {$nodes[1]->getTitle()} has been deleted.");
     $nids = \Drupal::entityQuery('node')
       ->allRevisions()
       ->accessCheck(FALSE)
@@ -203,11 +193,7 @@ public function testRevisions() {
       ->execute();
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert");
     $this->submitForm([], 'Revert');
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
-      '@type' => 'Basic page',
-      '%title' => $nodes[2]->getTitle(),
-      '%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
-    ]));
+    $this->assertSession()->pageTextContains("Basic page {$nodes[2]->getTitle()} has been reverted to the revision from {$this->container->get('date.formatter')->format($old_revision_date)}.");
 
     // Create 50 more revisions in order to trigger paging on the revisions
     // overview screen.
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
index 66e91c011a4e..fb0929bc09a4 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
@@ -173,11 +173,7 @@ public function testRevisions() {
     // Confirm that revisions revert properly.
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert");
     $this->submitForm([], 'Revert');
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
-      '@type' => 'Basic page',
-      '%title' => $nodes[1]->label(),
-      '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
-    ]));
+    $this->assertSession()->pageTextContains("Basic page {$nodes[1]->label()} has been reverted to the revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())}.");
     $node_storage->resetCache([$node->id()]);
     $reverted_node = $node_storage->load($node->id());
     $this->assertSame($nodes[1]->body->value, $reverted_node->body->value, 'Node reverted correctly.');
@@ -193,11 +189,7 @@ public function testRevisions() {
     // Confirm revisions delete properly.
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete");
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', [
-      '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
-      '@type' => 'Basic page',
-      '%title' => $nodes[1]->label(),
-    ]));
+    $this->assertSession()->pageTextContains("Revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())} of Basic page {$nodes[1]->label()} has been deleted.");
     $connection = Database::getConnection();
     $nids = \Drupal::entityQuery('node')
       ->accessCheck(FALSE)
@@ -218,11 +210,7 @@ public function testRevisions() {
       ->execute();
     $this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert");
     $this->submitForm([], 'Revert');
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
-      '@type' => 'Basic page',
-      '%title' => $nodes[2]->label(),
-      '%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
-    ]));
+    $this->assertSession()->pageTextContains("Basic page {$nodes[2]->label()} has been reverted to the revision from {$this->container->get('date.formatter')->format($old_revision_date)}.");
 
     // Make a new revision and set it to not be default.
     // This will create a new revision that is not "front facing".
diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
index f8d4c023b21c..ac02282f1b2b 100644
--- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -494,13 +494,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('<em>Edit @type</em> @title [%language translation]', [
-          '@type' => $type_name,
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("Edit {$type_name} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php
index 8c8e8b26588a..1128a858c12b 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php
@@ -190,18 +190,14 @@ public function testNodeTypeDeletion() {
     $node = $this->drupalCreateNode(['type' => $type->id()]);
     // Attempt to delete the content type, which should not be allowed.
     $this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
-    $this->assertRaw(
-     t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', ['%type' => $type->label()])
-    );
+    $this->assertSession()->pageTextContains("{$type->label()} is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the {$type->label()} content.");
     $this->assertSession()->pageTextNotContains('This action cannot be undone.');
 
     // Delete the node.
     $node->delete();
     // Attempt to delete the content type, which should now be allowed.
     $this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
-    $this->assertRaw(
-      t('Are you sure you want to delete the content type %type?', ['%type' => $type->label()])
-    );
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the content type {$type->label()}?");
     $this->assertSession()->pageTextContains('This action cannot be undone.');
 
     // Test that a locked node type could not be deleted.
@@ -276,9 +272,9 @@ public function testNodeTypeNoContentType() {
 
     // Navigate to content type administration screen
     $this->drupalGet('admin/structure/types');
-    $this->assertRaw(t('No content types available. <a href=":link">Add content type</a>.', [
-        ':link' => Url::fromRoute('node.type_add')->toString(),
-      ]));
+    $this->assertSession()->pageTextContains("No content types available. Add content type.");
+    $this->assertSession()->linkExists("Add content type");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('node.type_add')->toString());
 
     $bundle_info->clearCachedBundles();
     $this->assertCount(0, $bundle_info->getBundleInfo('node'), 'The bundle information service has 0 bundles for the Node entity type.');
diff --git a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
index cd1aa7d091d1..fbfb37979404 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
@@ -121,7 +121,7 @@ public function testNodeTypeTranslation() {
     $this->drupalGet("$langcode/node/add/$type");
     // This is a Spanish page, so ensure the text asserted is translated in
     // Spanish and not French by adding the langcode option.
-    $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
+    $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
 
     // Check the name is translated with admin theme for editing.
     $this->drupalGet('admin/appearance');
@@ -129,7 +129,7 @@ public function testNodeTypeTranslation() {
     $this->drupalGet("$langcode/node/add/$type");
     // This is a Spanish page, so ensure the text asserted is translated in
     // Spanish and not French by adding the langcode option.
-    $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
+    $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
   }
 
   /**
diff --git a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
index 5556a59fe598..8aa4df106c5e 100644
--- a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
+++ b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
@@ -308,7 +308,7 @@ public function testSelectListSingle() {
     // Submit form: select invalid 'none' option.
     $edit = ['card_1' => '_none'];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getName()]));
+    $this->assertSession()->pageTextContains("{$field->getName()} field is required.");
 
     // Submit form: select first option.
     $edit = ['card_1' => 0];
diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php
index d508a5f8dd85..04acb78a1b20 100644
--- a/core/modules/path/tests/src/Functional/PathAliasTest.php
+++ b/core/modules/path/tests/src/Functional/PathAliasTest.php
@@ -148,21 +148,18 @@ public function testAdminAlias() {
     $this->submitForm($edit, 'Save');
 
     // Confirm no duplicate was created.
-    $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
+    $this->assertSession()->pageTextContains("The alias {$edit['alias[0][value]']} is already in use in this language.");
 
     $edit_upper = $edit;
     $edit_upper['alias[0][value]'] = mb_strtoupper($edit['alias[0][value]']);
     $this->drupalGet('admin/config/search/path/add');
     $this->submitForm($edit_upper, 'Save');
-    $this->assertRaw(t('The alias %alias could not be added because it is already in use in this language with different capitalization: %stored_alias.', [
-      '%alias' => $edit_upper['alias[0][value]'],
-      '%stored_alias' => $edit['alias[0][value]'],
-    ]));
+    $this->assertSession()->pageTextContains("The alias {$edit_upper['alias[0][value]']} could not be added because it is already in use in this language with different capitalization: {$edit['alias[0][value]']}.");
 
     // Delete alias.
     $this->drupalGet('admin/config/search/path/edit/' . $pid);
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the URL alias %name?', ['%name' => $edit['alias[0][value]']]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the URL alias {$edit['alias[0][value]']}?");
     $this->submitForm([], 'Delete');
 
     // Confirm that the alias no longer works.
@@ -233,7 +230,7 @@ public function testAdminAlias() {
     $edit['path[0][value]'] = '/node/' . $node3->id();
     $this->drupalGet('admin/config/search/path/edit/' . $pid);
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
+    $this->assertSession()->pageTextContains("The alias {$edit['alias[0][value]']} is already in use in this language.");
 
     // Create an alias without a starting slash.
     $node5 = $this->drupalCreateNode();
diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php
index ab237c402343..a578d9f27606 100644
--- a/core/modules/search/tests/src/Functional/SearchCommentTest.php
+++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php
@@ -178,7 +178,7 @@ public function testSearchResultsComment() {
     // Verify that comment is rendered using proper format.
     $this->assertSession()->pageTextContains($comment_body);
     // Verify that HTML in comment body is not hidden.
-    $this->assertNoRaw(t('n/a'));
+    $this->assertSession()->pageTextNotContains('n/a');
     $this->assertSession()->assertNoEscaped($edit_comment['comment_body[0][value]']);
 
     // Search for the evil script comment subject.
diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
index 8518df08055c..35d0fd16cd01 100644
--- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
@@ -149,7 +149,7 @@ public function testSearchModuleSettingsPage() {
     $this->submitForm($edit, 'Save search page');
 
     // Ensure that the modifications took effect.
-    $this->assertRaw(t('The %label search page has been updated.', ['%label' => 'Dummy search type']));
+    $this->assertSession()->pageTextContains("The Dummy search type search page has been updated.");
     $this->drupalGet('admin/config/search/pages/manage/dummy_search_type');
     $this->assertTrue($this->assertSession()->optionExists('edit-extra-type-settings-boost', 'ii')->isSelected());
   }
@@ -280,7 +280,7 @@ public function testMultipleSearchPages() {
     $first['path'] = strtolower($this->randomMachineName(8));
     $this->submitForm($first, 'Save');
     $this->assertDefaultSearch($first_id, 'The default page matches the only search page.');
-    $this->assertRaw(t('The %label search page has been added.', ['%label' => $first['label']]));
+    $this->assertSession()->pageTextContains("The {$first['label']} search page has been added.");
 
     // Attempt to add a search page with an existing path.
     $edit = [];
@@ -326,7 +326,7 @@ public function testMultipleSearchPages() {
 
     // Change the default search page.
     $this->clickLink('Set as default');
-    $this->assertRaw(t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $second['label']]));
+    $this->assertSession()->pageTextContains("The default search page is now {$second['label']}. Be sure to check the ordering of your search pages.");
     $this->verifySearchPageOperations($first_id, TRUE, TRUE, TRUE, FALSE);
     $this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE);
 
@@ -345,9 +345,9 @@ public function testMultipleSearchPages() {
 
     // Test deleting.
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the search page %label?', ['%label' => $first['label']]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the search page {$first['label']}?");
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The search page %label has been deleted.', ['%label' => $first['label']]));
+    $this->assertSession()->pageTextContains("The search page {$first['label']} has been deleted.");
     $this->verifySearchPageOperations($first_id, FALSE, FALSE, FALSE, FALSE);
   }
 
diff --git a/core/modules/search/tests/src/Functional/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
index 91d568d795ef..bb6d61865f89 100644
--- a/core/modules/search/tests/src/Functional/SearchPageTextTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
@@ -138,7 +138,7 @@ public function testSearchText() {
     $edit['keys'] = implode(' ', $keys);
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $limit]));
+    $this->assertSession()->pageTextContains("Your search used too many AND/OR expressions. Only the first {$limit} terms were included in this search.");
 
     // Test that a search on Node or User with no keywords entered generates
     // the "Please enter some keywords" message.
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
index e4182490220e..463340eedadf 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
@@ -116,7 +116,7 @@ public function testShortcutLinkAdd() {
     $this->drupalGet('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link');
     $this->submitForm($form_data, 'Save');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin']));
+    $this->assertSession()->pageTextContains("The path '/admin' is inaccessible.");
 
     $form_data = [
       'title[0][value]' => $title,
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
index 8c2d21aaeb7b..fc76f34d939a 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
@@ -93,7 +93,7 @@ public function testShortcutSetEdit() {
     }
 
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The shortcut set has been updated.'));
+    $this->assertSession()->pageTextContains("The shortcut set has been updated.");
 
     \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache();
     // Check to ensure that the shortcut weights have changed and that
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
index a32eedc705e2..0d0a80d6a53c 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
@@ -104,12 +104,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('@title [%language translation]', [
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
index 32faab1b34c1..ff355952f7ea 100644
--- a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
+++ b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
@@ -32,7 +32,7 @@ public function testDrupalMessengerService() {
     // then removes the first before it is displayed.
     $this->drupalGet(Url::fromRoute('system_test.messenger_service'));
     $this->assertSession()->pageTextNotContains('First message (removed).');
-    $this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
+    $this->assertSession()->responseContains('Second message with <em>markup!</em> (not removed).');
 
     // Ensure duplicate messages are handled as expected.
     $this->assertSession()->pageTextMatchesCount(1, '/Non Duplicated message/');
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
index 6a5f7c6f8778..1f5cb69bd22c 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
@@ -88,7 +88,7 @@ public function testEntityFormLanguage() {
     $edit = ['language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED];
     $this->drupalGet('admin/structure/types/manage/page');
     $this->submitForm($edit, 'Save content type');
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']));
+    $this->assertSession()->pageTextContains("The content type Basic page has been updated.");
 
     // Create a node with language.
     $edit = [];
diff --git a/core/modules/system/tests/src/Functional/Form/EmailTest.php b/core/modules/system/tests/src/Functional/Form/EmailTest.php
index a32115233c57..422b0dcdc928 100644
--- a/core/modules/system/tests/src/Functional/Form/EmailTest.php
+++ b/core/modules/system/tests/src/Functional/Form/EmailTest.php
@@ -33,8 +33,8 @@ public function testFormEmail() {
     $edit['email_required'] = ' ';
     $this->drupalGet('form-test/email');
     $this->submitForm($edit, 'Submit');
-    $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
-    $this->assertRaw(t('@name field is required.', ['@name' => 'Address']));
+    $this->assertSession()->pageTextContains("The email address invalid is not valid.");
+    $this->assertSession()->pageTextContains("Address field is required.");
 
     $edit = [];
     $edit['email_required'] = '  foo.bar@example.com ';
diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php
index e87ab2e9a3a2..eec3ee307e6a 100644
--- a/core/modules/system/tests/src/Functional/Form/FormTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormTest.php
@@ -380,7 +380,7 @@ public function testCheckboxProcessing() {
     $edit = [];
     $this->drupalGet('form-test/checkbox');
     $this->submitForm($edit, 'Submit');
-    $this->assertRaw(t('@name field is required.', ['@name' => 'required_checkbox']));
+    $this->assertSession()->pageTextContains("required_checkbox field is required.");
 
     // Now try to submit the form correctly.
     $this->submitForm(['required_checkbox' => 1], 'Submit');
@@ -721,7 +721,7 @@ public function testColorValidation() {
       ];
       $this->drupalGet('form-test/color');
       $this->submitForm($edit, 'Submit');
-      $this->assertRaw(t('%name must be a valid color.', ['%name' => 'Color']));
+      $this->assertSession()->pageTextContains("Color must be a valid color.");
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
index 4456b33e2a3d..b6aea0ead694 100644
--- a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
+++ b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
@@ -58,7 +58,7 @@ public function testFormStateValuesCleanAdvanced() {
 
     // Expecting a 200 HTTP code.
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->pageTextContains("You WIN!");
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Form/UrlTest.php b/core/modules/system/tests/src/Functional/Form/UrlTest.php
index b6e2a1a51904..26ff068528ee 100644
--- a/core/modules/system/tests/src/Functional/Form/UrlTest.php
+++ b/core/modules/system/tests/src/Functional/Form/UrlTest.php
@@ -35,8 +35,8 @@ public function testFormUrl() {
     $edit['url_required'] = ' ';
     $this->drupalGet('form-test/url');
     $this->submitForm($edit, 'Submit');
-    $this->assertRaw(t('The URL %url is not valid.', ['%url' => 'http://']));
-    $this->assertRaw(t('@name field is required.', ['@name' => 'Required URL']));
+    $this->assertSession()->pageTextContains("The URL http:// is not valid.");
+    $this->assertSession()->pageTextContains("Required URL field is required.");
 
     $edit = [];
     $edit['url'] = "\n";
diff --git a/core/modules/system/tests/src/Functional/Form/ValidationTest.php b/core/modules/system/tests/src/Functional/Form/ValidationTest.php
index 7cac1f9b13fa..0738c34b23db 100644
--- a/core/modules/system/tests/src/Functional/Form/ValidationTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ValidationTest.php
@@ -152,9 +152,9 @@ public function testValidateLimitErrors() {
    * Tests #pattern validation.
    */
   public function testPatternValidation() {
-    $textfield_error = t('%name field is not in the right format.', ['%name' => 'One digit followed by lowercase letters']);
-    $tel_error = t('%name field is not in the right format.', ['%name' => 'Everything except numbers']);
-    $password_error = t('%name field is not in the right format.', ['%name' => 'Password']);
+    $textfield_error = 'One digit followed by lowercase letters field is not in the right format.';
+    $tel_error = 'Everything except numbers field is not in the right format.';
+    $password_error = 'Password field is not in the right format.';
 
     // Invalid textfield, valid tel.
     $edit = [
@@ -163,9 +163,9 @@ public function testPatternValidation() {
     ];
     $this->drupalGet('form-test/pattern');
     $this->submitForm($edit, 'Submit');
-    $this->assertRaw($textfield_error);
-    $this->assertNoRaw($tel_error);
-    $this->assertNoRaw($password_error);
+    $this->assertSession()->pageTextContains($textfield_error);
+    $this->assertSession()->pageTextNotContains($tel_error);
+    $this->assertSession()->pageTextNotContains($password_error);
 
     // Valid textfield, invalid tel, valid password.
     $edit = [
@@ -175,9 +175,9 @@ public function testPatternValidation() {
     ];
     $this->drupalGet('form-test/pattern');
     $this->submitForm($edit, 'Submit');
-    $this->assertNoRaw($textfield_error);
-    $this->assertRaw($tel_error);
-    $this->assertNoRaw($password_error);
+    $this->assertSession()->pageTextNotContains($textfield_error);
+    $this->assertSession()->pageTextContains($tel_error);
+    $this->assertSession()->pageTextNotContains($password_error);
 
     // Non required fields are not validated if empty.
     $edit = [
@@ -186,9 +186,9 @@ public function testPatternValidation() {
     ];
     $this->drupalGet('form-test/pattern');
     $this->submitForm($edit, 'Submit');
-    $this->assertNoRaw($textfield_error);
-    $this->assertNoRaw($tel_error);
-    $this->assertNoRaw($password_error);
+    $this->assertSession()->pageTextNotContains($textfield_error);
+    $this->assertSession()->pageTextNotContains($tel_error);
+    $this->assertSession()->pageTextNotContains($password_error);
 
     // Invalid password.
     $edit = [
@@ -196,9 +196,9 @@ public function testPatternValidation() {
     ];
     $this->drupalGet('form-test/pattern');
     $this->submitForm($edit, 'Submit');
-    $this->assertNoRaw($textfield_error);
-    $this->assertNoRaw($tel_error);
-    $this->assertRaw($password_error);
+    $this->assertSession()->pageTextNotContains($textfield_error);
+    $this->assertSession()->pageTextNotContains($tel_error);
+    $this->assertSession()->pageTextContains($password_error);
 
     // The pattern attribute overrides #pattern and is not validated on the
     // server side.
@@ -209,7 +209,7 @@ public function testPatternValidation() {
     ];
     $this->drupalGet('form-test/pattern');
     $this->submitForm($edit, 'Submit');
-    $this->assertNoRaw(t('%name field is not in the right format.', ['%name' => 'Client side validation']));
+    $this->assertSession()->pageTextNotContains('Client side validation field is not in the right format.');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
index fcf15f2eb58b..b30550613cbc 100644
--- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php
+++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
@@ -66,7 +66,8 @@ public function testMissingModules() {
     // Test that the system_dependencies_test module is marked
     // as missing a dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]));
+    $this->assertSession()->pageTextContains(Unicode::ucfirst('_missing_dependency') . ' (missing)');
+    $this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-dependencies-test"]//span[@class="admin-missing"]', 'missing');
     $this->assertSession()->checkboxNotChecked('modules[system_dependencies_test][enable]');
   }
 
@@ -78,10 +79,8 @@ public function testIncompatibleModuleVersionDependency() {
     // Test that the system_incompatible_module_version_dependencies_test is
     // marked as having an incompatible dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
-      '@module' => 'System incompatible module version test (>2.0)',
-      '@version' => '1.0',
-    ]));
+    $this->assertSession()->pageTextContains('System incompatible module version test (>2.0) (incompatible with version 1.0)');
+    $this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-module-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
     $this->assertSession()->fieldDisabled('modules[system_incompatible_module_version_dependencies_test][enable]');
   }
 
@@ -92,9 +91,8 @@ public function testIncompatibleCoreVersionDependency() {
     // Test that the system_incompatible_core_version_dependencies_test is
     // marked as having an incompatible dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
-      '@module' => 'System core incompatible semver test',
-    ]));
+    $this->assertSession()->pageTextContains('System core incompatible semver test (incompatible with this version of Drupal core)');
+    $this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-core-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
     $this->assertSession()->fieldDisabled('modules[system_incompatible_core_version_dependencies_test][enable]');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php b/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
index 97015201e4b0..6bdc5a2b78be 100644
--- a/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
+++ b/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
@@ -33,7 +33,7 @@ public function testResponses() {
 
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Controller response successfully rendered.'));
+    $this->assertSession()->pageTextContains("Controller response successfully rendered.");
 
     // Test that correct response code is returned for any non-HTML format.
     foreach (['json', 'hal+json', 'xml', 'foo'] as $format) {
@@ -43,7 +43,7 @@ public function testResponses() {
 
       $this->drupalGet($url);
       $this->assertSession()->statusCodeEquals(406);
-      $this->assertNoRaw(t('Controller response successfully rendered.'));
+      $this->assertSession()->pageTextNotContains("Controller response successfully rendered.");
     }
 
     // Test that event subscriber does not interfere with raw string responses.
@@ -53,7 +53,7 @@ public function testResponses() {
 
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Raw controller response.'));
+    $this->assertSession()->responseContains("Raw controller response.");
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
index 16e7ee75206b..44aebf2b0935 100644
--- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php
+++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
@@ -144,7 +144,7 @@ public function testDateFormatConfiguration() {
     $this->submitForm([], 'Delete');
     // Verify that the user is redirected to the correct page.
     $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection'));
-    $this->assertRaw(t('The date format %format has been deleted.', ['%format' => $name]));
+    $this->assertSession()->pageTextContains("The date format {$name} has been deleted.");
 
     // Make sure the date does not exist in config.
     $date_format = DateFormat::load($date_format_id);
diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
index 684e195d2323..6b9b6316e180 100644
--- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
+++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
@@ -59,7 +59,7 @@ public function testSiteMaintenance() {
     $permission_label = $permissions['access site in maintenance mode']['title'];
     $permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => Url::fromRoute('user.admin_permissions')->toString(), ':user-login' => Url::fromRoute('user.login')->toString()]);
     $this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
-    $this->assertRaw($permission_message);
+    $this->assertSession()->responseContains($permission_message);
 
     $this->drupalGet(Url::fromRoute('user.page'));
     // JS should be aggregated, so drupal.js is not in the page source.
@@ -80,7 +80,7 @@ public function testSiteMaintenance() {
     // JS should not be aggregated, so drupal.js is expected in the page source.
     $links = $this->xpath('//script[contains(@src, :href)]', [':href' => '/core/misc/drupal.js']);
     $this->assertTrue(isset($links[0]), 'script /core/misc/drupal.js in page');
-    $this->assertRaw($admin_message);
+    $this->assertSession()->responseContains($admin_message);
 
     // Logout and verify that offline message is displayed.
     $this->drupalLogout();
@@ -113,7 +113,7 @@ public function testSiteMaintenance() {
     $this->drupalLogout();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config/development/maintenance');
-    $this->assertNoRaw($admin_message);
+    $this->assertSession()->responseNotContains($admin_message);
 
     $offline_message = 'Sorry, not online.';
     $edit = [
@@ -125,7 +125,7 @@ public function testSiteMaintenance() {
     $this->drupalLogout();
     $this->drupalGet('');
     $this->assertEquals('Site under maintenance', $this->cssSelect('main h1')[0]->getText());
-    $this->assertRaw($offline_message);
+    $this->assertSession()->pageTextContains($offline_message);
 
     // Verify that custom site offline message is not displayed on user/password.
     $this->drupalGet('user/password');
diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php
index 1beb8513289b..562c491d1cf6 100644
--- a/core/modules/system/tests/src/Functional/System/StatusTest.php
+++ b/core/modules/system/tests/src/Functional/System/StatusTest.php
@@ -63,7 +63,7 @@ public function testStatusPage() {
     $this->assertSession()->pageTextNotContains('Out of date');
 
     // The setting config_sync_directory is not properly formed.
-    $this->assertRaw(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]));
+    $this->assertSession()->pageTextContains("Your {$this->siteDirectory}/settings.php file must define the \$settings['config_sync_directory'] setting");
 
     /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
     $update_registry = \Drupal::service('update.update_hook_registry');
diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
index 9cc455ad66a5..f0b7c570ae32 100644
--- a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
+++ b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
@@ -38,8 +38,8 @@ public function testStatusPageWithoutConfiguration() {
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(t('Trusted Host Settings'));
-    $this->assertRaw(t('The trusted_host_patterns setting is not configured in settings.php.'));
+    $this->assertSession()->pageTextContains("Trusted Host Settings");
+    $this->assertSession()->pageTextContains("The trusted_host_patterns setting is not configured in settings.php.");
   }
 
   /**
@@ -56,8 +56,8 @@ public function testStatusPageWithConfiguration() {
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(t('Trusted Host Settings'));
-    $this->assertRaw(t('The trusted_host_patterns setting is set to allow'));
+    $this->assertSession()->pageTextContains("Trusted Host Settings");
+    $this->assertSession()->pageTextContains("The trusted_host_patterns setting is set to allow");
   }
 
   /**
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
index badf7be91411..049da47d1483 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
@@ -173,12 +173,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('@title [%language translation]', [
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
index 2e4ff36ab832..d94f17bd57e7 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
@@ -269,11 +269,11 @@ public function testVocabularyPermissionsTaxonomyTerm() {
 
     // Delete the vocabulary.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
-    $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]']]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the taxonomy term {$edit['name[0][value]']}?");
 
     // Confirm deletion.
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]));
+    $this->assertSession()->pageTextContains("Deleted term {$edit['name[0][value]']}.");
 
     // Test as user with "create" permissions.
     $user = $this->drupalCreateUser(["create terms in {$vocabulary->id()}"]);
@@ -348,11 +348,11 @@ public function testVocabularyPermissionsTaxonomyTerm() {
 
     // Delete the vocabulary.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
-    $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $term->getName()]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the taxonomy term {$term->getName()}?");
 
     // Confirm deletion.
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('Deleted term %name.', ['%name' => $term->getName()]));
+    $this->assertSession()->pageTextContains("Deleted term {$term->getName()}.");
 
     // Test as user without proper permissions.
     $user = $this->drupalCreateUser();
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
index 9a75d84f3c48..47bdfdb62900 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
@@ -47,7 +47,7 @@ public function testVocabularyInterface() {
     $edit['description'] = $this->randomMachineName();
     $edit['vid'] = $vid;
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Created new vocabulary %name.', ['%name' => $edit['name']]));
+    $this->assertSession()->pageTextContains("Created new vocabulary {$edit['name']}.");
 
     // Edit the vocabulary.
     $this->drupalGet('admin/structure/taxonomy');
@@ -155,12 +155,12 @@ public function testTaxonomyAdminDeletingVocabulary() {
     // Delete the vocabulary.
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
     $this->clickLink('Delete');
-    $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()]));
+    $this->assertSession()->pageTextContains("Are you sure you want to delete the vocabulary {$vocabulary->label()}?");
     $this->assertSession()->pageTextContains('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.');
 
     // Confirm deletion.
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('Deleted vocabulary %name.', ['%name' => $vocabulary->label()]));
+    $this->assertSession()->pageTextContains("Deleted vocabulary {$vocabulary->label()}.");
     $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache();
     $this->assertNull(Vocabulary::load($vid), 'Vocabulary not found.');
   }
diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
index dc5aae50a8c4..ed2a4853106c 100644
--- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
@@ -91,7 +91,7 @@ public function testUploadModule() {
     $this->assertSession()->titleEquals('Update manager | Drupal');
     // Check for a success message on the page, and check that the installed
     // module now exists in the expected place in the filesystem.
-    $this->assertRaw(t('Added / updated %project_name successfully', ['%project_name' => 'update_test_new_module']));
+    $this->assertSession()->pageTextContains("Added / updated update_test_new_module successfully");
     $this->assertFileExists($installedInfoFilePath);
     // Ensure the links are relative to the site root and not
     // core/authorize.php.
@@ -138,7 +138,7 @@ public function testUploadModule() {
     $this->submitForm(['projects[update_test_new_module]' => TRUE], 'Download these updates');
     $this->submitForm(['maintenance_mode' => FALSE], 'Continue');
     $this->assertSession()->pageTextContains('Update was completed successfully.');
-    $this->assertRaw(t('Added / updated %project_name successfully', ['%project_name' => 'update_test_new_module']));
+    $this->assertSession()->pageTextContains("Added / updated update_test_new_module successfully");
 
     // Parse the info file again to check that the module has been updated to
     // 8.x-1.1.
diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php
index 4f0db35fd506..ae5cb39fdc56 100644
--- a/core/modules/user/tests/src/Functional/UserCancelTest.php
+++ b/core/modules/user/tests/src/Functional/UserCancelTest.php
@@ -57,7 +57,7 @@ public function testUserCancelWithoutPermission() {
 
     // Attempt to cancel account.
     $this->drupalGet('user/' . $account->id() . '/edit');
-    $this->assertNoRaw(t('Cancel account'));
+    $this->assertSession()->pageTextNotContains("Cancel account");
 
     // Attempt bogus account cancellation request confirmation.
     $timestamp = $account->getLastLoginTime();
@@ -92,7 +92,7 @@ public function testUserCancelChangePermission() {
     $this->submitForm([], 'Cancel account');
 
     // Confirm deletion.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been deleted.");
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
@@ -208,7 +208,7 @@ public function testUserBlock() {
     $this->assertTrue($account->isBlocked(), 'User has been blocked.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been disabled.");
   }
 
   /**
@@ -265,7 +265,7 @@ public function testUserBlockUnpublish() {
     $this->assertSession()->addressEquals('');
     $this->assertSession()->statusCodeEquals(200);
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been disabled.");
 
     $user_storage->resetCache([$account->id()]);
     $account = $user_storage->load($account->id());
@@ -374,7 +374,7 @@ public function testUserAnonymize() {
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->submitForm([], 'Cancel account');
     $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?');
-    $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]));
+    $this->assertSession()->pageTextContains("Your account will be removed and all account information deleted. All of your content will be assigned to the {$this->config('user.settings')->get('anonymous')} user.");
 
     // Confirm account cancellation.
     $timestamp = time();
@@ -408,7 +408,7 @@ public function testUserAnonymize() {
     $this->assertEquals($anonymous_user->getDisplayName(), $test_comment->getAuthorName(), 'Comment of the user has been attributed to anonymous user name.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been deleted.");
   }
 
   /**
@@ -438,7 +438,7 @@ public function testUserAnonymizeBatch() {
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->submitForm([], 'Cancel account');
     $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?');
-    $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]));
+    $this->assertSession()->pageTextContains("Your account will be removed and all account information deleted. All of your content will be assigned to the {$this->config('user.settings')->get('anonymous')} user.");
 
     // Confirm account cancellation.
     $timestamp = time();
@@ -538,7 +538,7 @@ public function testUserDelete() {
     $this->assertNull(Comment::load($comment->id()), 'Comment of the user has been deleted.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been deleted.");
   }
 
   /**
@@ -557,12 +557,12 @@ public function testUserCancelByAdmin() {
     // Delete regular user.
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->submitForm([], 'Cancel account');
-    $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("Are you sure you want to cancel the account {$account->getAccountName()}?");
     $this->assertSession()->pageTextContains('Select the method to cancel the account above.');
 
     // Confirm deletion.
     $this->submitForm([], 'Cancel account');
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been deleted.");
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
@@ -585,12 +585,12 @@ public function testUserWithoutEmailCancelByAdmin() {
     // Delete regular user without email address.
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->submitForm([], 'Cancel account');
-    $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("Are you sure you want to cancel the account {$account->getAccountName()}?");
     $this->assertSession()->pageTextContains('Select the method to cancel the account above.');
 
     // Confirm deletion.
     $this->submitForm([], 'Cancel account');
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("{$account->getAccountName()} has been deleted.");
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
diff --git a/core/modules/user/tests/src/Functional/UserCreateTest.php b/core/modules/user/tests/src/Functional/UserCreateTest.php
index d9905cdc3b12..fa4513cf96d2 100644
--- a/core/modules/user/tests/src/Functional/UserCreateTest.php
+++ b/core/modules/user/tests/src/Functional/UserCreateTest.php
@@ -88,11 +88,11 @@ public function testUserAdd() {
 
     $config->set('password_strength', TRUE)->save();
     $this->drupalGet('admin/people/create');
-    $this->assertRaw(t('Password strength:'));
+    $this->assertSession()->responseContains("Password strength:");
 
     $config->set('password_strength', FALSE)->save();
     $this->drupalGet('admin/people/create');
-    $this->assertNoRaw(t('Password strength:'));
+    $this->assertSession()->responseNotContains("Password strength:");
 
     // We create two users, notifying one and not notifying the other, to
     // ensure that the tests work in both cases.
diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php
index 99e1f24e86d3..11533bfb2d89 100644
--- a/core/modules/user/tests/src/Functional/UserEditTest.php
+++ b/core/modules/user/tests/src/Functional/UserEditTest.php
@@ -30,7 +30,7 @@ public function testUserEdit() {
     $edit['name'] = $user2->getAccountName();
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The username %name is already taken.', ['%name' => $edit['name']]));
+    $this->assertSession()->pageTextContains("The username {$edit['name']} is already taken.");
 
     // Check that the default value in user name field
     // is the raw value and not a formatted one.
@@ -65,12 +65,12 @@ public function testUserEdit() {
     $edit['mail'] = $this->randomMachineName() . '@new.example.com';
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')]));
+    $this->assertSession()->pageTextContains("Your current password is missing or incorrect; it's required to change the Email.");
 
     $edit['current_pass'] = $user1->passRaw;
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->pageTextContains("The changes have been saved.");
 
     // Test that the user must enter current password before changing passwords.
     $edit = [];
@@ -78,13 +78,13 @@ public function testUserEdit() {
     $edit['pass[pass2]'] = $new_pass;
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')]));
+    $this->assertSession()->pageTextContains("Your current password is missing or incorrect; it's required to change the Password.");
 
     // Try again with the current password.
     $edit['current_pass'] = $user1->passRaw;
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->pageTextContains("The changes have been saved.");
 
     // Confirm there's only one session in the database as the existing session
     // has been migrated when the password is changed.
@@ -107,12 +107,12 @@ public function testUserEdit() {
     $config->set('password_strength', TRUE)->save();
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Password strength:'));
+    $this->assertSession()->responseContains("Password strength:");
 
     $config->set('password_strength', FALSE)->save();
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertNoRaw(t('Password strength:'));
+    $this->assertSession()->responseNotContains("Password strength:");
 
     // Check that the user status field has the correct value and that it is
     // properly displayed.
@@ -154,7 +154,7 @@ public function testUserWith0Password() {
     $edit = ['pass[pass1]' => '0', 'pass[pass2]' => '0'];
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->pageTextContains("The changes have been saved.");
   }
 
   /**
@@ -171,7 +171,7 @@ public function testUserWithoutEmailEdit() {
     $user1->save();
     $this->drupalGet("user/" . $user1->id() . "/edit");
     $this->submitForm(['mail' => ''], 'Save');
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->pageTextContains("The changes have been saved.");
   }
 
   /**
diff --git a/core/modules/user/tests/src/Functional/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php
index 4f4b84a4e200..778f1744853c 100644
--- a/core/modules/user/tests/src/Functional/UserLoginTest.php
+++ b/core/modules/user/tests/src/Functional/UserLoginTest.php
@@ -215,12 +215,16 @@ public function assertFailedLogin($account, $flood_trigger = NULL) {
         ->execute()
         ->fetchField();
       if ($flood_trigger == 'user') {
-        $this->assertRaw(\Drupal::translation()->formatPlural($this->config('user.flood')->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
+        $this->assertSession()->pageTextMatches("/There (has|have) been more than \w+ failed login attempt.* for this account. It is temporarily blocked. Try again later or request a new password./");
+        $this->assertSession()->linkExists("request a new password");
+        $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass')->toString());
         $this->assertEquals('Flood control blocked login attempt for uid %uid from %ip', $last_log, 'A watchdog message was logged for the login attempt blocked by flood control per user.');
       }
       else {
         // No uid, so the limit is IP-based.
-        $this->assertRaw(t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
+        $this->assertSession()->pageTextContains("Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or request a new password.");
+        $this->assertSession()->linkExists("request a new password");
+        $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass')->toString());
         $this->assertEquals('Flood control blocked login attempt from %ip', $last_log, 'A watchdog message was logged for the login attempt blocked by flood control per IP.');
       }
     }
diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
index cc7b77969af1..85c3e1986bec 100644
--- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
@@ -378,8 +378,9 @@ public function testUserResetPasswordTextboxFilled() {
     ];
     $this->drupalGet('user/login');
     $this->submitForm($edit, 'Log in');
-    $this->assertRaw(t('Unrecognized username or password. <a href=":password">Forgot your password?</a>',
-      [':password' => Url::fromRoute('user.pass', [], ['query' => ['name' => $edit['name']]])->toString()]));
+    $this->assertSession()->pageTextContains("Unrecognized username or password. Forgot your password?");
+    $this->assertSession()->linkExists("Forgot your password?");
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass', [], ['query' => ['name' => $edit['name']]])->toString());
     unset($edit['pass']);
     $this->drupalGet('user/password', ['query' => ['name' => $edit['name']]]);
     $this->assertSession()->fieldValueEquals('name', $edit['name']);
diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php
index 8938a6da9f6e..465c74d3a298 100644
--- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php
+++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php
@@ -353,12 +353,12 @@ public function testRegistrationWithUserFields() {
     $edit['test_user_field[0][value]'] = '';
     $this->submitForm($edit, 'Create new account');
     $this->assertRegistrationFormCacheTagsWithUserFields();
-    $this->assertRaw(t('@name field is required.', ['@name' => $field->label()]));
+    $this->assertSession()->pageTextContains("{$field->label()} field is required.");
     // Invalid input.
     $edit['test_user_field[0][value]'] = '-1';
     $this->submitForm($edit, 'Create new account');
     $this->assertRegistrationFormCacheTagsWithUserFields();
-    $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $field->label()]));
+    $this->assertSession()->pageTextContains("{$field->label()} does not accept the value -1.");
 
     // Submit with valid data.
     $value = rand(1, 255);
diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
index 6ec8b156810a..b37fa75d6f2a 100644
--- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
+++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
@@ -61,7 +61,7 @@ public function testRoleAdministration() {
     $edit = ['label' => $role_name, 'id' => $role_name];
     $this->drupalGet('admin/people/roles/add');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Role %label has been added.', ['%label' => 123]));
+    $this->assertSession()->pageTextContains("Role 123 has been added.");
     $role = Role::load($role_name);
     $this->assertIsObject($role);
 
@@ -71,14 +71,14 @@ public function testRoleAdministration() {
     // Try adding a duplicate role.
     $this->drupalGet('admin/people/roles/add');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
+    $this->assertSession()->pageTextContains("The machine-readable name is already in use. It must be unique.");
 
     // Test renaming a role.
     $role_name = '456';
     $edit = ['label' => $role_name];
     $this->drupalGet("admin/people/roles/manage/{$role->id()}");
     $this->submitForm($edit, 'Save');
-    $this->assertRaw(t('Role %label has been updated.', ['%label' => $role_name]));
+    $this->assertSession()->pageTextContains("Role {$role_name} has been updated.");
     \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
     $new_role = Role::load($role->id());
     $this->assertEquals($role_name, $new_role->label(), 'The role name has been successfully changed.');
@@ -87,7 +87,7 @@ public function testRoleAdministration() {
     $this->drupalGet("admin/people/roles/manage/{$role->id()}");
     $this->clickLink('Delete');
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name]));
+    $this->assertSession()->pageTextContains("Role {$role_name} has been deleted.");
     $this->assertSession()->linkByHrefNotExists("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
     \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
     $this->assertNull(Role::load($role->id()), 'A deleted role can no longer be loaded.');
diff --git a/core/modules/user/tests/src/Functional/UserTranslationUITest.php b/core/modules/user/tests/src/Functional/UserTranslationUITest.php
index 8e04b858ccde..7ba1a2b9ec01 100644
--- a/core/modules/user/tests/src/Functional/UserTranslationUITest.php
+++ b/core/modules/user/tests/src/Functional/UserTranslationUITest.php
@@ -86,12 +86,7 @@ protected function doTestTranslationEdit() {
         $options = ['language' => $languages[$langcode]];
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
-
-        $title = t('@title [%language translation]', [
-          '@title' => $entity->getTranslation($langcode)->label(),
-          '%language' => $languages[$langcode]->getName(),
-        ]);
-        $this->assertRaw($title);
+        $this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
       }
     }
   }
diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
index a3bdbddddfe9..3d434de1f90a 100644
--- a/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
@@ -107,7 +107,7 @@ public function testAdminUserInterface() {
     ];
     $this->drupalGet($path);
     $this->submitForm($edit, 'Apply');
-    $this->assertRaw(t('There are no users matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
 
     // Pass in an invalid username and a valid username.
     $random_name = $this->randomMachineName();
@@ -119,7 +119,7 @@ public function testAdminUserInterface() {
     $users = [$users[0]];
     $this->drupalGet($path);
     $this->submitForm($edit, 'Apply');
-    $this->assertRaw(t('There are no users matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
 
     // Pass in just valid usernames.
     $users = $this->names;
@@ -129,7 +129,7 @@ public function testAdminUserInterface() {
     ];
     $this->drupalGet($path);
     $this->submitForm($edit, 'Apply');
-    $this->assertNoRaw(t('There are no users matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->pageTextNotContains('There are no users matching "' . implode(', ', $users) . '".');
   }
 
   /**
@@ -145,7 +145,7 @@ public function testExposedFilter() {
     $users = array_map('strtolower', $users);
     $options['query']['uid'] = implode(', ', $users);
     $this->drupalGet($path, $options);
-    $this->assertRaw(t('There are no users matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
 
     // Pass in an invalid target_id in for the entity_autocomplete value format.
     // There should be no errors, but all results should be returned as the
@@ -165,7 +165,7 @@ public function testExposedFilter() {
     $users = [$users[0]];
 
     $this->drupalGet($path, $options);
-    $this->assertRaw(t('There are no users matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->pageTextContains('There are no users matching "' . implode(', ', $users) . '".');
 
     // Pass in just valid usernames.
     $users = $this->names;
diff --git a/core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php b/core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
index 005e65c30ac7..2ccbb47daeb3 100644
--- a/core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
@@ -105,13 +105,7 @@ public function testArgumentDefaultNoOptions() {
     $this->submitForm($edit, 'Apply');
 
     // Note, the undefined index error has two spaces after it.
-    $error = [
-      '%type' => 'Notice',
-      '@message' => 'Undefined index:  ' . $argument_type,
-      '%function' => 'views_handler_argument->validateOptionsForm()',
-    ];
-    $message = t('%type: @message in %function', $error);
-    $this->assertNoRaw($message);
+    $this->assertSession()->pageTextNotContains("Notice: Undefined index:  {$argument_type} in views_handler_argument->validateOptionsForm()");
   }
 
   /**
diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
index dc334a75681a..d2e9324995b3 100644
--- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
@@ -447,7 +447,7 @@ public function testFormErrorWithExposedForm() {
     $form = $this->cssSelect('form.views-exposed-form');
     $this->assertNotEmpty($form, 'The exposed form element was found.');
     // Ensure the exposed form is rendered before submitting the normal form.
-    $this->assertRaw(t('Apply'));
+    $this->assertSession()->responseContains("Apply");
     $this->assertRaw('<div class="views-row">');
 
     $this->submitForm([], 'Submit');
@@ -455,7 +455,7 @@ public function testFormErrorWithExposedForm() {
     $form = $this->cssSelect('form.views-exposed-form');
     $this->assertNotEmpty($form, 'The exposed form element was found.');
     // Ensure the exposed form is rendered after submitting the normal form.
-    $this->assertRaw(t('Apply'));
+    $this->assertSession()->responseContains("Apply");
     $this->assertRaw('<div class="views-row">');
   }
 
diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
index 6d843b5bb764..5e48df633892 100644
--- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
+++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
@@ -170,7 +170,7 @@ public function testViewsWizardAndListing() {
     $view4['rest_export[path]'] = $this->randomMachineName(16);
     $this->drupalGet('admin/structure/views/add');
     $this->submitForm($view4, 'Save and edit');
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => $view4['label']]));
+    $this->assertSession()->pageTextContains("The view {$view4['label']} has been saved.");
 
     // Check that the REST export path works. JSON will work, as all core
     // formats will be allowed. JSON and XML by default.
diff --git a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
index d97b5c532eb1..b0d3835322dc 100644
--- a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
@@ -70,7 +70,7 @@ public function testCacheData() {
     // Test we can save the view.
     $this->drupalGet('admin/structure/views/view/test_view/edit');
     $this->submitForm([], 'Save');
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
+    $this->assertSession()->pageTextContains("The view Test view has been saved.");
 
     // Test that a deleted view has no tempstore data.
     $this->drupalGet('admin/structure/views/nojs/display/test_view/default/title');
diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
index 48b099bbab8e..478f2a8e00ef 100644
--- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
@@ -118,7 +118,7 @@ public function testDeleteWithNoPath() {
     $this->submitForm([], 'Add Page');
     $this->submitForm([], 'Delete Page');
     $this->submitForm([], 'Save');
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
+    $this->assertSession()->pageTextContains("The view Test view has been saved.");
   }
 
   /**
diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
index 1ee8da342edc..6be6c457802e 100644
--- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
@@ -36,7 +36,7 @@ public function testDeleteLink() {
     $this->clickLink('Delete view');
     $this->assertSession()->addressEquals('admin/structure/views/view/test_view/delete');
     $this->submitForm([], 'Delete');
-    $this->assertRaw(t('The view %name has been deleted.', ['%name' => $view->label()]));
+    $this->assertSession()->pageTextContains("The view {$view->label()} has been deleted.");
 
     $this->assertSession()->addressEquals('admin/structure/views');
     $view = $this->container->get('entity_type.manager')->getStorage('view')->load('test_view');
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
index e720386d7fa6..142c88bb9ed5 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
@@ -67,9 +67,7 @@ public function testNonEnglishProfileWithoutLocaleModule() {
 
     // Verify that the confirmation message appears.
     require_once $this->root . '/core/includes/install.inc';
-    $this->assertRaw(t('Congratulations, you installed @drupal!', [
-      '@drupal' => drupal_install_profile_distribution_name(),
-    ]));
+    $this->assertSession()->pageTextContains('Congratulations, you installed Drupal!');
 
     $this->assertFalse(\Drupal::service('module_handler')->moduleExists('locale'), 'The Locale module is not installed.');
     $this->assertTrue(\Drupal::service('module_handler')->moduleExists('language'), 'The Language module is installed.');
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
index 868560ca83b3..92c402e7c3f3 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
@@ -29,9 +29,7 @@ public function testInstaller() {
 
     // Verify that the confirmation message appears.
     require_once $this->root . '/core/includes/install.inc';
-    $this->assertRaw(t('Congratulations, you installed @drupal!', [
-      '@drupal' => drupal_install_profile_distribution_name(),
-    ]));
+    $this->assertSession()->pageTextContains('Congratulations, you installed Drupal!');
 
     // Ensure that the timezone is correct for sites under test after installing
     // interactively.
-- 
GitLab