diff --git a/core/modules/action/tests/src/Functional/ActionListTest.php b/core/modules/action/tests/src/Functional/ActionListTest.php
index f481bd42cd98569658c5acec7f7e5d1cf531bb87..0f0869280d7834b219e77dfc8ade31a9c16bebc4 100644
--- a/core/modules/action/tests/src/Functional/ActionListTest.php
+++ b/core/modules/action/tests/src/Functional/ActionListTest.php
@@ -36,7 +36,7 @@ public function testEmptyActionList() {
     $actions = $storage->loadMultiple();
     $storage->delete($actions);
     $this->drupalGet('/admin/config/system/actions');
-    $this->assertRaw('There are no actions yet.');
+    $this->assertSession()->pageTextContains('There are no actions yet.');
   }
 
 }
diff --git a/core/modules/action/tests/src/Functional/ActionUninstallTest.php b/core/modules/action/tests/src/Functional/ActionUninstallTest.php
index ed5ab041f8f4e1b560818f79c4c80715cef7cbdd..1d718f0c531d3c659a7c93abde2629595eb31db2 100644
--- a/core/modules/action/tests/src/Functional/ActionUninstallTest.php
+++ b/core/modules/action/tests/src/Functional/ActionUninstallTest.php
@@ -40,7 +40,7 @@ public function testActionUninstall() {
 
     $this->drupalGet('admin/people');
     // Ensure we have the user_block_user_action listed.
-    $this->assertRaw('<option value="user_block_user_action">Block the selected user(s)</option>');
+    $this->assertSession()->responseContains('<option value="user_block_user_action">Block the selected user(s)</option>');
 
   }
 
diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
index 5e5ac32d06b4598dbbf3947cf183affff0d84f41..4ff2ca30abff6c4e9c69f65c0602da9d4fb7b5bf 100644
--- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
@@ -38,7 +38,7 @@ public function testAddFeed() {
     $this->assertSession()->statusCodeEquals(200);
     // Verify that the feed label is present in the page title.
     $this->assertSession()->pageTextContains($feed->label());
-    $this->assertRaw($feed->getWebsiteUrl());
+    $this->assertSession()->pageTextContains($feed->getWebsiteUrl());
 
     // Try to add a duplicate.
     $edit = [
diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
index 193a222145b276cf06368eae47fb81b0fee30df9..916510b706b315829af3ba9ccfd9e22081a32914 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
@@ -41,10 +41,10 @@ public function testRSS091Sample() {
     $this->assertSession()->pageTextContains('First example feed item title');
     $this->assertSession()->linkByHrefExists('http://example.com/example-turns-one');
     $this->assertSession()->pageTextContains('First example feed item description.');
-    $this->assertRaw('<img src="http://example.com/images/druplicon.png"');
+    $this->assertSession()->responseContains('<img src="http://example.com/images/druplicon.png"');
 
     // Several additional items that include elements over 255 characters.
-    $this->assertRaw("Second example feed item title.");
+    $this->assertSession()->pageTextContains("Second example feed item title.");
     $this->assertSession()->pageTextContains('Long link feed item title');
     $this->assertSession()->pageTextContains('Long link feed item description');
     $this->assertSession()->linkByHrefExists('http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing');
@@ -91,7 +91,7 @@ public function testHtmlEntitiesSample() {
     $feed->refreshItems();
     $this->drupalGet('aggregator/sources/' . $feed->id());
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw("Quote&quot; Amp&amp;");
+    $this->assertSession()->responseContains("Quote&quot; Amp&amp;");
   }
 
   /**
diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
index 39eddebf86d2bac41fd34ef683c04aa86f09df2f..62cd03281a5ac5ce367b2e822fc50455ff277602 100644
--- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
+++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
@@ -253,17 +253,17 @@ public function testControllerNotCalledBeforeAuth() {
     $this->assertSession()->statusCodeEquals(401);
     $this->drupalGet('/basic_auth_test/state/read');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('nope');
+    $this->assertSession()->pageTextContains('nope');
 
     $account = $this->drupalCreateUser();
     $this->basicAuthGet('/basic_auth_test/state/modify', $account->getAccountName(), $account->pass_raw);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Done');
+    $this->assertSession()->pageTextContains('Done');
 
     $this->mink->resetSessions();
     $this->drupalGet('/basic_auth_test/state/read');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('yep');
+    $this->assertSession()->pageTextContains('yep');
   }
 
 }
diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index e4fbb201786b9a620687098b8496142c3c46efd7..21a39eb5a45aab6cc733d230991db127fcc9b47f 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -95,12 +95,12 @@ public function testNoJsDetection() {
     $this->drupalLogin($this->rootUser);
     $this->assertSessionCookieExists(TRUE);
     $this->assertBigPipeNoJsCookieExists(FALSE);
-    $this->assertRaw('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . UrlHelper::encodePath(base_path() . 'user/1?check_logged_in=1') . '" />' . "\n" . '</noscript>');
+    $this->assertSession()->responseContains('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . UrlHelper::encodePath(base_path() . 'user/1?check_logged_in=1') . '" />' . "\n" . '</noscript>');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
     $this->assertBigPipeNoJsCookieExists(TRUE);
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
-    $this->assertRaw($no_js_to_js_markup);
+    $this->assertSession()->responseContains($no_js_to_js_markup);
     $this->drupalLogout();
 
     // Close the prior connection and remove the collected state.
@@ -111,12 +111,12 @@ public function testNoJsDetection() {
     $this->drupalGet(Url::fromRoute('user.login'));
     $this->assertSessionCookieExists(TRUE);
     $this->assertBigPipeNoJsCookieExists(FALSE);
-    $this->assertRaw('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/login" />' . "\n" . '</noscript>');
+    $this->assertSession()->responseContains('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/login" />' . "\n" . '</noscript>');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
     $this->assertBigPipeNoJsCookieExists(TRUE);
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
-    $this->assertRaw($no_js_to_js_markup);
+    $this->assertSession()->responseContains($no_js_to_js_markup);
 
     // Close the prior connection and remove the collected state.
     $this->getSession()->reset();
@@ -185,7 +185,7 @@ public function testBigPipe() {
       1 => $cases['html']->bigPipePlaceholderId,
     ]);
 
-    $this->assertRaw('</body>');
+    $this->assertSession()->responseContains('</body>');
 
     // Verifying BigPipe assets are present.
     $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
@@ -212,8 +212,8 @@ public function testBigPipe() {
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
     $this->drupalGet(Url::fromRoute('big_pipe_test'));
     // The 'edge_case__html_exception' case throws an exception.
-    $this->assertRaw('The website encountered an unexpected error. Please try again later');
-    $this->assertRaw('You are not allowed to say llamas are not cool!');
+    $this->assertSession()->pageTextContains('The website encountered an unexpected error. Please try again later');
+    $this->assertSession()->pageTextContains('You are not allowed to say llamas are not cool!');
     // Check that stop signal and closing body tag are absent.
     $this->assertSession()->responseNotContains(BigPipe::STOP_SIGNAL);
     $this->assertSession()->responseNotContains('</body>');
@@ -272,7 +272,7 @@ public function testBigPipeNoJs() {
     // Verifying BigPipe assets are absent.
     $this->assertArrayNotHasKey('bigPipePlaceholderIds', $this->getDrupalSettings());
     $this->assertArrayNotHasKey('ajaxPageState', $this->getDrupalSettings());
-    $this->assertRaw('</body>');
+    $this->assertSession()->responseContains('</body>');
 
     // Verify that 4xx responses work fine. (4xx responses are handled by
     // subrequests to a route pointing to a controller with the desired output.)
@@ -284,8 +284,8 @@ public function testBigPipeNoJs() {
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
     $this->drupalGet(Url::fromRoute('big_pipe_test'));
     // The 'edge_case__html_exception' case throws an exception.
-    $this->assertRaw('The website encountered an unexpected error. Please try again later');
-    $this->assertRaw('You are not allowed to say llamas are not cool!');
+    $this->assertSession()->pageTextContains('The website encountered an unexpected error. Please try again later');
+    $this->assertSession()->pageTextContains('You are not allowed to say llamas are not cool!');
     $this->assertSession()->responseNotContains('</body>');
     // The exception is expected. Do not interpret it as a test failure.
     unlink($this->root . '/' . $this->siteDirectory . '/error.log');
@@ -308,7 +308,7 @@ public function testBigPipeMultiOccurrencePlaceholders() {
     $this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
     $big_pipe_placeholder_id = 'callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&amp;args%5B0%5D&amp;token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA';
     $expected_placeholder_replacement = '<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="' . $big_pipe_placeholder_id . '">';
-    $this->assertRaw('The count is 1.');
+    $this->assertSession()->pageTextContains('The count is 1.');
     $this->assertSession()->responseNotContains('The count is 2.');
     $this->assertSession()->responseNotContains('The count is 3.');
     $raw_content = $this->getSession()->getPage()->getContent();
@@ -322,7 +322,7 @@ public function testBigPipeMultiOccurrencePlaceholders() {
     $this->performMetaRefresh();
     $this->assertBigPipeNoJsCookieExists(TRUE);
     $this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
-    $this->assertRaw('The count is 1.');
+    $this->assertSession()->pageTextContains('The count is 1.');
     $this->assertSession()->responseNotContains('The count is 2.');
     $this->assertSession()->responseNotContains('The count is 3.');
   }
@@ -348,7 +348,7 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
       // $big_pipe_nojs_placeholder is present.
       $this->assertSession()->responseNotContains($big_pipe_nojs_placeholder);
       if ($expected_replacement !== NULL) {
-        $this->assertRaw($expected_replacement);
+        $this->assertSession()->responseContains($expected_replacement);
       }
     }
   }
@@ -369,7 +369,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
     foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
       // Verify expected placeholder.
       $expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
-      $this->assertRaw($expected_placeholder_html);
+      $this->assertSession()->responseContains($expected_placeholder_html);
       $pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_html);
       $placeholder_positions[$pos] = $big_pipe_placeholder_id;
       // Verify expected placeholder replacement.
@@ -381,7 +381,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
         continue;
       }
       $this->assertEquals($expected_ajax_response, trim($result[0]->getText()));
-      $this->assertRaw($expected_placeholder_replacement);
+      $this->assertSession()->responseContains($expected_placeholder_replacement);
       $pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_replacement);
       $placeholder_replacement_positions[$pos] = $big_pipe_placeholder_id;
     }
@@ -400,8 +400,8 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
     $this->assertSame(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
 
     // Verifying BigPipe start/stop signals.
-    $this->assertRaw(BigPipe::START_SIGNAL);
-    $this->assertRaw(BigPipe::STOP_SIGNAL);
+    $this->assertSession()->responseContains(BigPipe::START_SIGNAL);
+    $this->assertSession()->responseContains(BigPipe::STOP_SIGNAL);
     $start_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::START_SIGNAL);
     $stop_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::STOP_SIGNAL);
     $this->assertTrue($start_signal_position < $stop_signal_position, 'BigPipe start signal appears before stop signal.');
diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php
index 140821922bfce9f75114be8684a9f1be50171eb5..5618a05e5b7a0253718c83a27bbb91b977dd5bf6 100644
--- a/core/modules/block/tests/src/Functional/BlockUiTest.php
+++ b/core/modules/block/tests/src/Functional/BlockUiTest.php
@@ -243,7 +243,7 @@ public function testContextAwareBlocks() {
     $this->drupalGet('');
     $this->assertSession()->pageTextContains('Test context-aware block');
     $this->assertSession()->pageTextContains('User context found.');
-    $this->assertRaw($expected_text);
+    $this->assertSession()->responseContains($expected_text);
 
     // Test context mapping form element is not visible if there are no valid
     // context options for the block (the test_context_aware_no_valid_context_options
diff --git a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
index 62d015d70f9cf94cfb50a387b259e31195a5fe13..6d56f6bea0db0063e5797eb7e79c5cf2da23288d 100644
--- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
+++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
@@ -386,8 +386,8 @@ public function testBlockContextualLinks() {
     $cached_id_token = Crypt::hmacBase64($cached_id, Settings::getHashSalt() . $this->container->get('private_key')->get());
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
     // Check existence of the contextual link placeholders.
-    $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token]) . '></div>');
-    $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token]) . '></div>');
+    $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token]) . '></div>');
+    $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token]) . '></div>');
 
     // Get server-rendered contextual links.
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
index 7179d9af5019bebce4dbba658c0c16bbd96eb4ff..4d46481bb1a04add5c9b108f95cf9c95f0d04631 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
@@ -123,7 +123,7 @@ public function testBlockContentTypeEditing() {
 
     // Verify that title and body fields are displayed.
     $this->drupalGet('block/add/basic');
-    $this->assertRaw('Block description');
+    $this->assertSession()->pageTextContains('Block description');
     $this->assertNotEmpty($this->cssSelect('#edit-body-0-value'), 'Body field was found.');
 
     // Change the block type name.
@@ -143,7 +143,7 @@ public function testBlockContentTypeEditing() {
     \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
 
     $this->drupalGet('block/add');
-    $this->assertRaw('Bar');
+    $this->assertSession()->pageTextContains('Bar');
     $this->clickLink('Bar');
     // Verify that the original machine name was used in the URL.
     $this->assertSession()->addressEquals(Url::fromRoute('block_content.add_form', ['block_content_type' => 'basic']));
diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php
index b3508a149ca746f19876a7724356bbba4b5c408a..15366c4f5a07d4bef6629834c21f59fa6aa174ad 100644
--- a/core/modules/book/tests/src/Functional/BookTest.php
+++ b/core/modules/book/tests/src/Functional/BookTest.php
@@ -130,23 +130,23 @@ public function testBookNavigationCacheContext() {
 
     // On non-node route.
     $this->drupalGet($this->adminUser->toUrl());
-    $this->assertRaw('[route.book_navigation]=book.none');
+    $this->assertSession()->responseContains('[route.book_navigation]=book.none');
 
     // On non-book node route.
     $this->drupalGet($page->toUrl());
-    $this->assertRaw('[route.book_navigation]=book.none');
+    $this->assertSession()->responseContains('[route.book_navigation]=book.none');
 
     // On book node route.
     $this->drupalGet($book_nodes[0]->toUrl());
-    $this->assertRaw('[route.book_navigation]=0|2|3');
+    $this->assertSession()->responseContains('[route.book_navigation]=0|2|3');
     $this->drupalGet($book_nodes[1]->toUrl());
-    $this->assertRaw('[route.book_navigation]=0|2|3|4');
+    $this->assertSession()->responseContains('[route.book_navigation]=0|2|3|4');
     $this->drupalGet($book_nodes[2]->toUrl());
-    $this->assertRaw('[route.book_navigation]=0|2|3|5');
+    $this->assertSession()->responseContains('[route.book_navigation]=0|2|3|5');
     $this->drupalGet($book_nodes[3]->toUrl());
-    $this->assertRaw('[route.book_navigation]=0|2|6');
+    $this->assertSession()->responseContains('[route.book_navigation]=0|2|6');
     $this->drupalGet($book_nodes[4]->toUrl());
-    $this->assertRaw('[route.book_navigation]=0|2|7');
+    $this->assertSession()->responseContains('[route.book_navigation]=0|2|7');
   }
 
   /**
@@ -256,7 +256,7 @@ public function testBookExport() {
     // Make sure each part of the book is there.
     foreach ($nodes as $node) {
       $this->assertSession()->pageTextContains($node->label());
-      $this->assertRaw($node->body->processed);
+      $this->assertSession()->responseContains($node->body->processed);
     }
 
     // Make sure we can't export an unsupported format.
diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php
index c2cb0a4d2c15cede8246286efb7fa6eea19b0ecb..508fafab4c138c9538b184766b4021fd1a5ea21d 100644
--- a/core/modules/book/tests/src/Functional/BookTestTrait.php
+++ b/core/modules/book/tests/src/Functional/BookTestTrait.php
@@ -104,14 +104,14 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
       $url = $previous->toUrl();
       $url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]);
       $text = new FormattableMarkup('<b>‹</b> @label', ['@label' => $previous->label()]);
-      $this->assertRaw(Link::fromTextAndUrl($text, $url)->toString());
+      $this->assertSession()->responseContains(Link::fromTextAndUrl($text, $url)->toString());
     }
 
     if ($up) {
       /** @var \Drupal\Core\Url $url */
       $url = $up->toUrl();
       $url->setOptions(['attributes' => ['title' => t('Go to parent page')]]);
-      $this->assertRaw(Link::fromTextAndUrl('Up', $url)->toString());
+      $this->assertSession()->responseContains(Link::fromTextAndUrl('Up', $url)->toString());
     }
 
     if ($next) {
@@ -119,7 +119,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
       $url = $next->toUrl();
       $url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]);
       $text = new FormattableMarkup('@label <b>›</b>', ['@label' => $next->label()]);
-      $this->assertRaw(Link::fromTextAndUrl($text, $url)->toString());
+      $this->assertSession()->responseContains(Link::fromTextAndUrl($text, $url)->toString());
     }
 
     // Compute the expected breadcrumb.
@@ -142,7 +142,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
     // Check printer friendly version.
     $this->drupalGet('book/export/html/' . $node->id());
     $this->assertSession()->pageTextContains($node->label());
-    $this->assertRaw($node->body->processed);
+    $this->assertSession()->responseContains($node->body->processed);
 
     $number++;
   }
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
index f101ed0a645ccf670f3cc74f90d5ba3a418aa4e1..686d7da6d6b4e1b9796e787e2708c93d71a08179 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
@@ -184,13 +184,13 @@ public function testExistingFormat() {
       return trim(Json::encode($html), '"');
     };
     // Check the Button separator.
-    $this->assertRaw($json_encode('<li data-drupal-ckeditor-button-name="-" class="ckeditor-button-separator ckeditor-multiple-button" data-drupal-ckeditor-type="separator"><a href="#" role="button" aria-label="Button separator" class="ckeditor-separator"></a></li>'));
+    $this->assertSession()->responseContains($json_encode('<li data-drupal-ckeditor-button-name="-" class="ckeditor-button-separator ckeditor-multiple-button" data-drupal-ckeditor-type="separator"><a href="#" role="button" aria-label="Button separator" class="ckeditor-separator"></a></li>'));
     // Check the Format dropdown.
-    $this->assertRaw($json_encode('<li data-drupal-ckeditor-button-name="Format" class="ckeditor-button"><a href="#" role="button" aria-label="Format"><span class="ckeditor-button-dropdown">Format<span class="ckeditor-button-arrow"></span></span></a></li>'));
+    $this->assertSession()->responseContains($json_encode('<li data-drupal-ckeditor-button-name="Format" class="ckeditor-button"><a href="#" role="button" aria-label="Format"><span class="ckeditor-button-dropdown">Format<span class="ckeditor-button-arrow"></span></span></a></li>'));
     // Check the Styles dropdown.
-    $this->assertRaw($json_encode('<li data-drupal-ckeditor-button-name="Styles" class="ckeditor-button"><a href="#" role="button" aria-label="Styles"><span class="ckeditor-button-dropdown">Styles<span class="ckeditor-button-arrow"></span></span></a></li>'));
+    $this->assertSession()->responseContains($json_encode('<li data-drupal-ckeditor-button-name="Styles" class="ckeditor-button"><a href="#" role="button" aria-label="Styles"><span class="ckeditor-button-dropdown">Styles<span class="ckeditor-button-arrow"></span></span></a></li>'));
     // Check strikethrough.
-    $this->assertRaw($json_encode('<li data-drupal-ckeditor-button-name="Strike" class="ckeditor-button"><a href="#" class="cke-icon-only cke_ltr" role="button" title="strike" aria-label="strike"><span class="cke_button_icon cke_button__strike_icon">strike</span></a></li>'));
+    $this->assertSession()->responseContains($json_encode('<li data-drupal-ckeditor-button-name="Strike" class="ckeditor-button"><a href="#" class="cke-icon-only cke_ltr" role="button" title="strike" aria-label="strike"><span class="cke_button_icon cke_button__strike_icon">strike</span></a></li>'));
 
     // Now enable the ckeditor_test module, which provides one configurable
     // CKEditor plugin — this should not affect the Editor config entity.
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
index 40e43050fac2004eeeb9ac8dc86ebd4ae0e38a89..a76b5b8b2fc77be2e547d46c12ec2e52fb30f93f 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
@@ -79,7 +79,7 @@ public function testImageButtonDisplay() {
     /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
     $file_url_generator = \Drupal::service('file_url_generator');
     $markup = $json_encode($file_url_generator->generateString('core/modules/ckeditor/js/plugins/drupalimage/icons/drupalimage.png'));
-    $this->assertRaw($markup);
+    $this->assertSession()->responseContains($markup);
   }
 
 }
diff --git a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php
index 7520cb5a5282f3d6123f500a4ed07df4618ed8cc..943cafcdf78b49c8fc0bbfbdff0688fda8572938 100644
--- a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php
+++ b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php
@@ -56,7 +56,7 @@ public function testColorPreview() {
     $this->assertSession()->pageTextContains('TEST COLOR PREVIEW');
 
     $this->assertSession()->responseNotContains('<script>alert("security filter test");</script>');
-    $this->assertRaw('<h2>TEST COLOR PREVIEW</h2>');
+    $this->assertSession()->responseContains('<h2>TEST COLOR PREVIEW</h2>');
   }
 
 }
diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php
index d919d17eaa5dbbeeb4e69b835ed51599c92d85ad..7925f5600d835711aeda10f49f07833cc8f731b7 100644
--- a/core/modules/color/tests/src/Functional/ColorTest.php
+++ b/core/modules/color/tests/src/Functional/ColorTest.php
@@ -217,7 +217,7 @@ public function testOverrideAndResetScheme() {
     // Make sure the color logo is not being used.
     $this->assertSession()->responseNotContains('files/color/bartik-');
     // Make sure the original bartik logo exists.
-    $this->assertRaw('bartik/logo.svg');
+    $this->assertSession()->responseContains('bartik/logo.svg');
 
     // Log in and set the color scheme to 'slate'.
     $this->drupalLogin($this->bigUser);
@@ -229,7 +229,7 @@ public function testOverrideAndResetScheme() {
     $this->drupalLogout();
     $this->drupalGet('');
     // Make sure the color logo is being used.
-    $this->assertRaw('files/color/bartik-');
+    $this->assertSession()->responseContains('files/color/bartik-');
     // Make sure the original bartik logo does not exist.
     $this->assertSession()->responseNotContains('bartik/logo.svg');
 
@@ -245,7 +245,7 @@ public function testOverrideAndResetScheme() {
     // Make sure the color logo is not being used.
     $this->assertSession()->responseNotContains('files/color/bartik-');
     // Make sure the original bartik logo exists.
-    $this->assertRaw('bartik/logo.svg');
+    $this->assertSession()->responseContains('bartik/logo.svg');
   }
 
 }
diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
index cbc3991f7032d399aaea8697d9c2090c7a77551b..e82ec2ecab4ae05c138cac3e4e5e42c4222cf471 100644
--- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
@@ -279,8 +279,8 @@ public function testCommentedTranslationDeletion() {
     ];
     $this->drupalGet('admin/content/comment');
     $this->submitForm($edit, 'Update');
-    $this->assertRaw(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment1->label()]));
-    $this->assertRaw(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment2->label()]));
+    $this->assertSession()->responseContains(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment1->label()]));
+    $this->assertSession()->responseContains(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment2->label()]));
     $this->assertSession()->pageTextContains('English');
     $this->assertSession()->pageTextContains('Urdu');
     $this->submitForm([], 'Delete');
diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
index d9ae7a1a524173a9ec4aa28ebe5fc503c86b584d..203793118d835920108a52f9ccdffa21092ecbf4 100644
--- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
@@ -137,22 +137,22 @@ public function testAnonymous() {
     // Make sure the user data appears correctly when editing the comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('comment/' . $anonymous_comment3->id() . '/edit');
-    $this->assertRaw($author_name);
+    $this->assertSession()->responseContains($author_name);
     // Check the author field is empty (i.e. anonymous) when editing the comment.
     $this->assertSession()->fieldValueEquals('uid', '');
-    $this->assertRaw($author_mail);
+    $this->assertSession()->responseContains($author_mail);
 
     // Unpublish comment.
     $this->performCommentOperation($anonymous_comment3, 'unpublish');
 
     $this->drupalGet('admin/content/comment/approval');
-    $this->assertRaw('comments[' . $anonymous_comment3->id() . ']');
+    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']');
 
     // Publish comment.
     $this->performCommentOperation($anonymous_comment3, 'publish', TRUE);
 
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $anonymous_comment3->id() . ']');
+    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']');
 
     // Delete comment.
     $this->performCommentOperation($anonymous_comment3, 'delete');
diff --git a/core/modules/comment/tests/src/Functional/CommentBlockTest.php b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
index 1392b0556e9a61e9da4d270d9152c45a613f294c..ac72aeae0f8b8e6b0f9e9648fd0a2cc970df5dff 100644
--- a/core/modules/comment/tests/src/Functional/CommentBlockTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
@@ -87,7 +87,7 @@ public function testRecentCommentBlock() {
     for ($i = 0; $i < 10; $i++) {
       $this->clickLink($comments[$i]->getSubject());
       $this->assertSession()->pageTextContains($comments[$i]->getSubject());
-      $this->assertRaw('<link rel="canonical"');
+      $this->assertSession()->responseContains('<link rel="canonical"');
     }
   }
 
diff --git a/core/modules/comment/tests/src/Functional/CommentCSSTest.php b/core/modules/comment/tests/src/Functional/CommentCSSTest.php
index 3aee0b75753ca31852e0e8807cb48af4f653c429..a9096af51b426b97c2d64b6253bb80ec72fd1a4e 100644
--- a/core/modules/comment/tests/src/Functional/CommentCSSTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentCSSTest.php
@@ -115,7 +115,7 @@ public function testCommentClasses() {
         // user (the viewer) was the author of the comment. We do this in Java-
         // Script to prevent breaking the render cache.
         $this->assertCount(1, $this->xpath('//*[contains(@class, "comment") and @data-comment-user-id="' . $case['comment_uid'] . '"]'), 'data-comment-user-id attribute is set on comment.');
-        $this->assertRaw($this->getModulePath('comment') . '/js/comment-by-viewer.js');
+        $this->assertSession()->responseContains($this->getModulePath('comment') . '/js/comment-by-viewer.js');
       }
 
       // Verify the unpublished class.
diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
index 7a0b96dccad85f7d3a23a27627c587b61f571c96..1440743eb19a9d1de17276601fb0643c98b79803 100644
--- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
@@ -318,7 +318,7 @@ public function testViewMode() {
     // Comment displayed in 'default' display mode found and has body text.
     $comment_element = $this->cssSelect('.comment-wrapper');
     $this->assertTrue(!empty($comment_element));
-    $this->assertRaw('<p>' . $comment_text . '</p>');
+    $this->assertSession()->responseContains('<p>' . $comment_text . '</p>');
 
     // Create a new comment entity view mode.
     $mode = mb_strtolower($this->randomMachineName());
diff --git a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
index cc34d59fa75cf114e14b970decf6f24e04829158..4759e0f322ac7e50b0bb1689072592b20d932248 100644
--- a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
@@ -156,7 +156,7 @@ public function testCommentLanguage() {
     $this->drupalGet('admin/content/comment');
     foreach ($comment_values as $node_values) {
       foreach ($node_values as $value) {
-        $this->assertRaw($value);
+        $this->assertSession()->responseContains($value);
       }
     }
   }
diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
index 255a51d8d90ce3d6d49d89c24ec67d6d5f8cdc70..3ee86bb675524f360ecd1074c59f8fa6c3220feb 100644
--- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
@@ -314,12 +314,12 @@ public function testCommentFunctionality() {
     // Unpublish the comment.
     $this->performCommentOperation($comment1, 'unpublish');
     $this->drupalGet('admin/content/comment/approval');
-    $this->assertRaw('comments[' . $comment1->id() . ']');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']');
 
     // Publish the comment.
     $this->performCommentOperation($comment1, 'publish', TRUE);
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $comment1->id() . ']');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']');
 
     // Delete the comment.
     $this->performCommentOperation($comment1, 'delete');
@@ -332,7 +332,7 @@ public function testCommentFunctionality() {
 
     // Check that the comment was found.
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $comment1->id() . ']');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']');
 
     // Check that entity access applies to administrative page.
     $this->assertSession()->pageTextContains($this->entity->label());
diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
index 430a098f627e1b561121a5c273024c61424731b0..6e3d1b853378b227e99af34e3a59955ad2c9d90a 100644
--- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
@@ -383,25 +383,25 @@ public function testTwoPagers() {
     // shown.
     $this->drupalGet('node/' . $node->id());
     $this->assertSession()->pageTextContains('next');
-    $this->assertRaw('Comment 1 on field comment');
-    $this->assertRaw('Comment 1 on field comment_2');
+    $this->assertSession()->pageTextContains('Comment 1 on field comment');
+    $this->assertSession()->pageTextContains('Comment 1 on field comment_2');
     // Navigate to next page of field 1.
     $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']);
     // Check only one pager updated.
-    $this->assertRaw('Comment 2 on field comment');
-    $this->assertRaw('Comment 1 on field comment_2');
+    $this->assertSession()->pageTextContains('Comment 2 on field comment');
+    $this->assertSession()->pageTextContains('Comment 1 on field comment_2');
     // Return to page 1.
     $this->drupalGet('node/' . $node->id());
     // Navigate to next page of field 2.
     $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment_2']);
     // Check only one pager updated.
-    $this->assertRaw('Comment 1 on field comment');
-    $this->assertRaw('Comment 2 on field comment_2');
+    $this->assertSession()->pageTextContains('Comment 1 on field comment');
+    $this->assertSession()->pageTextContains('Comment 2 on field comment_2');
     // Navigate to next page of field 1.
     $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']);
     // Check only one pager updated.
-    $this->assertRaw('Comment 2 on field comment');
-    $this->assertRaw('Comment 2 on field comment_2');
+    $this->assertSession()->pageTextContains('Comment 2 on field comment');
+    $this->assertSession()->pageTextContains('Comment 2 on field comment_2');
   }
 
   /**
diff --git a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
index 69afa90ea847a42d8638fdc6e35667de6f9e1b79..23222f1fb54acc33d610a1362cf93bbb65cebcf6 100644
--- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
@@ -58,7 +58,7 @@ public function testCommentPreview() {
     $this->submitForm($edit, 'Preview');
     $this->assertInstanceOf(MarkupInterface::class, $this->webUser->getDisplayName());
     $this->assertSession()->assertNoEscaped('<em>' . $this->webUser->id() . '</em>');
-    $this->assertRaw('<em>' . $this->webUser->id() . '</em>');
+    $this->assertSession()->responseContains('<em>' . $this->webUser->id() . '</em>');
 
     // Add a user picture.
     $image = current($this->drupalGetTestFiles('image'));
diff --git a/core/modules/comment/tests/src/Functional/CommentRssTest.php b/core/modules/comment/tests/src/Functional/CommentRssTest.php
index 611a636d6103bb6626da6a66b9ba0c1910959130..3f2a244ac17848093ff9ea291b7325b6dd0845a0 100644
--- a/core/modules/comment/tests/src/Functional/CommentRssTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentRssTest.php
@@ -72,7 +72,7 @@ public function testCommentRss() {
     ]));
 
     $raw = '<comments>' . $this->node->toUrl('canonical', ['fragment' => 'comments', 'absolute' => TRUE])->toString() . '</comments>';
-    $this->assertRaw($raw);
+    $this->assertSession()->responseContains($raw);
 
     // Hide comments from RSS feed and check presence.
     $this->node->set('comment', CommentItemInterface::HIDDEN);
diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
index 49a4eddc4dc9e8d5395412181e1c60290df9912b..d246b463edc6a8770f436cf5f7e65c753ad7b396 100644
--- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
@@ -114,7 +114,7 @@ public function testCommentTypeEditing() {
     $this->submitForm($edit, 'Save');
 
     $this->drupalGet('admin/structure/comment');
-    $this->assertRaw('Bar');
+    $this->assertSession()->pageTextContains('Bar');
     $this->clickLink('Manage fields');
     // Verify that the original machine name was used in the URL.
     $this->assertSession()->addressEquals(Url::fromRoute('entity.comment.field_ui_fields', ['comment_type' => 'comment']));
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
index 1a96f247f6d03d16a9cfd5dc368ee73fe3ba3212..aa58a411ec679c69a3d9be0f749eaf04eb9d38f3 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
@@ -273,14 +273,14 @@ public function testPager() {
     $this->drupalGet('admin/structure/config_test');
 
     // Item 51 should not be present.
-    $this->assertRaw('Test config entity 50');
+    $this->assertSession()->pageTextContains('Test config entity 50');
     $this->assertSession()->responseNotContains('Test config entity 51');
 
     // Browse to the next page, test config entity 51 is on page 2.
     $this->clickLink('Page 2');
     $this->assertSession()->responseNotContains('Test config entity 50');
-    $this->assertRaw('dotted.default');
-    $this->assertRaw('Test config entity 51');
+    $this->assertSession()->responseContains('dotted.default');
+    $this->assertSession()->pageTextContains('Test config entity 51');
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
index 73858fd7aaeee6aab852079a6684f748dcc458b8..3ea900bc6fcc5c4d1fe5712f4d4e4338ab775486 100644
--- a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
@@ -192,7 +192,7 @@ public function testExportImport() {
     $this->assertSession()->pageTextContains('The following items in your active configuration have changes since the last import that may be lost on the next import.');
     // Ensure the item is displayed as part of a list (to avoid false matches
     // on the rest of the page) and that the list markup is not escaped.
-    $this->assertRaw('<li>system.site</li>');
+    $this->assertSession()->responseContains('<li>system.site</li>');
     // Remove everything from sync. The warning about differences between the
     // active and snapshot should no longer exist.
     \Drupal::service('config.storage.sync')->deleteAll();
@@ -213,7 +213,7 @@ public function testExportImport() {
     $this->assertSession()->pageTextContains('The following items in your active configuration have changes since the last import that may be lost on the next import.');
     // Ensure the item is displayed as part of a list (to avoid false matches
     // on the rest of the page) and that the list markup is not escaped.
-    $this->assertRaw('<li>system.site</li>');
+    $this->assertSession()->responseContains('<li>system.site</li>');
   }
 
   /**
diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
index 22d4b909c74bcca24635ba21aac83d21c34f3666..5d3ee5c3fd1a3e42457718cd77d6ba8da507cf37 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
@@ -119,11 +119,11 @@ public function testImport() {
 
     // Verify that both appear as ready to import.
     $this->drupalGet('admin/config/development/configuration');
-    $this->assertRaw('<td>' . $name);
-    $this->assertRaw('<td>' . $dynamic_name);
-    $this->assertRaw('<td>core.extension');
-    $this->assertRaw('<td>system.theme');
-    $this->assertRaw('<td>automated_cron.settings');
+    $this->assertSession()->responseContains('<td>' . $name);
+    $this->assertSession()->responseContains('<td>' . $dynamic_name);
+    $this->assertSession()->responseContains('<td>core.extension');
+    $this->assertSession()->responseContains('<td>system.theme');
+    $this->assertSession()->responseContains('<td>automated_cron.settings');
     $this->assertSession()->buttonExists('Import all');
 
     // Import and verify that both do not appear anymore.
@@ -193,9 +193,9 @@ public function testImport() {
 
     // Verify that both appear as ready to import.
     $this->drupalGet('admin/config/development/configuration');
-    $this->assertRaw('<td>core.extension');
-    $this->assertRaw('<td>system.theme');
-    $this->assertRaw('<td>automated_cron.settings');
+    $this->assertSession()->responseContains('<td>core.extension');
+    $this->assertSession()->responseContains('<td>system.theme');
+    $this->assertSession()->responseContains('<td>automated_cron.settings');
 
     // Import and verify that both do not appear anymore.
     $this->submitForm([], 'Import all');
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
index 780542869620eac8453ba7fa4f89672cf576a1f7..fc27b7d9bd80323172b4a5fc0fa46dedca86503f 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
@@ -140,7 +140,7 @@ public function testPreExistingConfigInstall() {
       'modules[config_test][enable]' => TRUE,
       'modules[config_install_fail_test][enable]' => TRUE,
     ], 'Install');
-    $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
+    $this->assertSession()->responseContains('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
 
     // Uninstall the config_test module to test the confirm form.
     $this->drupalGet('admin/modules/uninstall');
@@ -154,7 +154,7 @@ public function testPreExistingConfigInstall() {
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_install_fail_test][enable]' => TRUE], 'Install');
     $this->submitForm([], 'Continue');
-    $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
+    $this->assertSession()->responseContains('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
 
     // Test that collection configuration clashes during a module install are
     // reported correctly.
@@ -168,7 +168,7 @@ public function testPreExistingConfigInstall() {
 
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_install_fail_test][enable]' => TRUE], 'Install');
-    $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
+    $this->assertSession()->responseContains('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
 
     // Test installing a theme through the UI that has existing configuration.
     // This relies on the fact the config_test has been installed and created
@@ -177,7 +177,7 @@ public function testPreExistingConfigInstall() {
     $this->drupalGet('admin/appearance');
     $url = $this->xpath("//a[contains(@href,'config_clash_test_theme') and contains(@href,'/install?')]/@href")[0];
     $this->drupalGet($this->getAbsoluteUrl($url->getText()));
-    $this->assertRaw('Unable to install config_clash_test_theme, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
+    $this->assertSession()->responseContains('Unable to install config_clash_test_theme, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
 
     // Test installing a theme through the API that has existing configuration.
     try {
@@ -202,13 +202,13 @@ public function testUnmetDependenciesInstall() {
     $this->submitForm(['modules[config_test][enable]' => TRUE], 'Install');
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_install_dependency_test][enable]' => TRUE], 'Install');
-    $this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
+    $this->assertSession()->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
 
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_test_language][enable]' => TRUE], 'Install');
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_install_dependency_test][enable]' => TRUE], 'Install');
-    $this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
+    $this->assertSession()->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
 
     $this->drupalGet('admin/modules');
     $this->submitForm(['modules[config_other_module_config_test][enable]' => TRUE], 'Install');
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
index 535f7e4e33dadbff8120609685bf2306c2fe81e4..c7815b65bac4617bd093e6e58071254246aec1a5 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
@@ -122,7 +122,7 @@ public function testMapperListPage() {
 
       $title = $test_entity->label() . ' ' . $entity_type->getSingularLabel();
       $title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
-      $this->assertRaw($title);
+      $this->assertSession()->responseContains($title);
       $this->assertSession()->responseContains('<th>Language</th>');
 
       $this->drupalGet($base_url);
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
index 0fa289de80d78af1f3d8e003bde46ca514414fe8..c67db412d1d3fbe68bc6095cd770f3904278b1d2 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
@@ -161,8 +161,8 @@ public function testSiteInformationTranslationUi() {
     $this->clickLink('Add');
 
     // Make sure original text is present on this page.
-    $this->assertRaw($site_name);
-    $this->assertRaw($site_slogan);
+    $this->assertSession()->pageTextContains($site_name);
+    $this->assertSession()->pageTextContains($site_slogan);
 
     // Update site name and slogan for French.
     $edit = [
@@ -189,8 +189,8 @@ public function testSiteInformationTranslationUi() {
 
     // Check French translation of site name and slogan are in place.
     $this->drupalGet('fr');
-    $this->assertRaw($fr_site_name);
-    $this->assertRaw($fr_site_slogan);
+    $this->assertSession()->pageTextContains($fr_site_name);
+    $this->assertSession()->pageTextContains($fr_site_slogan);
 
     // Visit French site to ensure base language string present as source.
     $this->drupalGet("fr/$translation_base_url/fr/edit");
@@ -486,7 +486,7 @@ public function testDateFormatTranslation() {
       $this->assertSession()->pageTextContains($label);
 
       // Make sure that the date library is added.
-      $this->assertRaw('core/modules/system/js/system.date.js');
+      $this->assertSession()->responseContains('core/modules/system/js/system.date.js');
 
       // Update translatable fields.
       $edit = [
@@ -616,8 +616,8 @@ public function testViewsTranslationUI() {
     $this->clickLink('Add');
 
     // Make sure original text is present on this page.
-    $this->assertRaw($description);
-    $this->assertRaw($human_readable_name);
+    $this->assertSession()->pageTextContains($description);
+    $this->assertSession()->pageTextContains($human_readable_name);
 
     // Update Views Fields for French.
     $edit = [
@@ -679,7 +679,7 @@ public function testPluralConfigStringsSourceElements() {
       // Check if the expected number of source elements are present.
       foreach ($data['expected'] as $index => $expected) {
         if ($expected) {
-          $this->assertRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
+          $this->assertSession()->responseContains('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
         }
         else {
           $this->assertSession()->responseNotContains('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
@@ -713,7 +713,7 @@ public function testPluralConfigStrings() {
 
     // Make sure original text is present on this page, in addition to 2 new
     // empty fields.
-    $this->assertRaw($description);
+    $this->assertSession()->pageTextContains($description);
     $this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', $field_value);
     $this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', $field_value_plural);
     $this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', '');
@@ -1088,7 +1088,7 @@ public function testNodeFieldTranslation() {
 
     // Check that the translations are saved.
     $this->clickLink('Add');
-    $this->assertRaw('FR label');
+    $this->assertSession()->responseContains('FR label');
   }
 
   /**
diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
index 6340c5e2424370d6b51a1a683f7ca6b6c34f0006..820201eea234c4bc5a7578bfa6afa56a3a3c333f 100644
--- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
@@ -114,7 +114,7 @@ public function testSendPersonalContactMessage() {
       '@sender_email' => $this->webUser->getEmail(),
       '@recipient_name' => $this->contactUser->getAccountName(),
     ];
-    $this->assertRaw(new FormattableMarkup('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
+    $this->assertSession()->responseContains(new FormattableMarkup('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
     // Ensure an unescaped version of the email does not exist anywhere.
     $this->assertSession()->responseNotContains($this->webUser->getEmail());
 
diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
index 1ed46eb4cfc58694eb858dbb89174da671ceda9b..d9511b7b90a2a92ce06521ed34f39e922cec4a93 100644
--- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
@@ -489,7 +489,7 @@ public function testAutoReply() {
     $this->assertCount(0, $captured_emails);
     $this->drupalLogin($admin_user);
     $this->drupalGet('admin/reports/dblog');
-    $this->assertRaw('Error sending auto-reply, missing sender e-mail address in foo');
+    $this->assertSession()->responseContains('Error sending auto-reply, missing sender e-mail address in foo');
   }
 
   /**
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php
index 4f61a71922bdd4fe1e3b1e1cac977f45f8d46cea..bd0ed4f1dcc24f66257c3be0c1b686d190b476ad 100644
--- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php
@@ -26,7 +26,7 @@ public function testNotModerated() {
     $this->assertSession()->pageTextContains('The content type Not moderated has been added.');
     $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'not_moderated');
     $this->drupalGet('node/add/not_moderated');
-    $this->assertRaw('Save');
+    $this->assertSession()->pageTextContains('Save');
     $this->submitForm([
       'title[0][value]' => 'Test',
     ], 'Save');
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php
index 4bcd1f8914a92b9f1b0bf82a9fde568b98a0cfed..a461f1a89817f842ae3d5a32b8463bc894efce18 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php
@@ -70,7 +70,7 @@ public function testEnable() {
     $this->drupalGet('admin/structure/types/add');
     $this->submitForm($edit, 'Save content type');
     $this->drupalGet('admin/config/regional/content-language');
-    $this->assertRaw('entity_types[node]');
+    $this->assertSession()->responseContains('entity_types[node]');
   }
 
 }
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
index 4276763b663cc27b16b7725ee6ce20018da09397..19382b412d4bcc5b6865d097b2250fadec11344e 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
@@ -141,7 +141,7 @@ public function testTitleDoesNotChangesOnChangingLanguageWidgetAndTriggeringAjax
     $node = $this->getNodeByTitle('english_title');
     $this->drupalGet('node/' . $node->id() . '/edit');
     // Test the expected title when loading the form.
-    $this->assertRaw('<title>Edit Article english_title | Drupal</title>');
+    $this->assertSession()->titleEquals('Edit Article english_title | Drupal');
     // Upload and image after changing the node language.
     $images = $this->drupalGetTestFiles('image')[1];
     $edit = [
@@ -151,7 +151,7 @@ public function testTitleDoesNotChangesOnChangingLanguageWidgetAndTriggeringAjax
     $this->submitForm($edit, 'Upload');
     // Test the expected title after triggering an ajax call with a new
     // language selected.
-    $this->assertRaw('<title>Edit Article english_title | Drupal</title>');
+    $this->assertSession()->titleEquals('Edit Article english_title | Drupal');
     $edit = [
       'langcode[0][value]' => 'en',
       'field_image_field[0][alt]' => 'alternative_text',
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
index 93486ebe200551a57d2fbe08396d46827bf54406..0068f2bad21d3c21853185edb77b8a34ebf78b2a 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -117,7 +117,7 @@ protected function doTestBasicTranslation() {
     // Assert that HTML is not escaped unexpectedly.
     if ($this->testHTMLEscapeForAllLanguages) {
       $this->assertSession()->responseNotContains('&lt;span class=&quot;translation-entity-all-languages&quot;&gt;(all languages)&lt;/span&gt;');
-      $this->assertRaw('<span class="translation-entity-all-languages">(all languages)</span>');
+      $this->assertSession()->responseContains('<span class="translation-entity-all-languages">(all languages)</span>');
     }
 
     // Ensure that the content language cache context is not yet added to the
@@ -525,7 +525,7 @@ protected function doTestTranslationEdit() {
         $url = $entity->toUrl('edit-form', $options);
         $this->drupalGet($url);
 
-        $this->assertRaw($entity->getTranslation($langcode)->label());
+        $this->assertSession()->responseContains($entity->getTranslation($langcode)->label());
       }
     }
   }
diff --git a/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php b/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
index 546d950f197cf939a38e5b9ecd9fda231a51cbc5..34e3e61b2f800869a58b709445084d260d39deb9 100644
--- a/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
+++ b/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
@@ -157,7 +157,7 @@ public function testDifferentPermissions() {
     // Get a page where contextual links are directly rendered.
     $this->drupalGet(Url::fromRoute('menu_test.contextual_test'));
     $this->assertSession()->assertEscaped("<script>alert('Welcome to the jungle!')</script>");
-    $this->assertRaw('<li class="menu-testcontextual-hidden-manage-edit"><a href="' . base_path() . 'menu-test-contextual/1/edit" class="use-ajax" data-dialog-type="modal" data-is-something>Edit menu - contextual</a></li>');
+    $this->assertSession()->responseContains('<li class="menu-testcontextual-hidden-manage-edit"><a href="' . base_path() . 'menu-test-contextual/1/edit" class="use-ajax" data-dialog-type="modal" data-is-something>Edit menu - contextual</a></li>');
   }
 
   /**
diff --git a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
index c4f5b021b2f1d17eb0a2f5de9272c976829fefe4..469155e84959c33c32b0d4560b637273c3e535e6 100644
--- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
+++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
@@ -78,7 +78,7 @@ public function testDateField() {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-      $this->assertRaw($date->format($date_format));
+      $this->assertSession()->responseContains($date->format($date_format));
       $this->assertSession()->responseNotContains($date->format($time_format));
 
       // Verify the date doesn't change if using a timezone that is UTC+12 when
@@ -273,8 +273,8 @@ public function testDatetimeField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-    $this->assertRaw($date->format($date_format));
-    $this->assertRaw($date->format($time_format));
+    $this->assertSession()->responseContains($date->format($date_format));
+    $this->assertSession()->responseContains($date->format($time_format));
 
     /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
     $display_repository = \Drupal::service('entity_display.repository');
diff --git a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
index 3f65bdb0fc8912e13d146ab4efc56db2b90c67cc..77a21941a1ea8e95ed1e07a2cce16122952f8914 100644
--- a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
+++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
@@ -93,9 +93,9 @@ public function testDateRangeField() {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-      $this->assertRaw($start_date->format($date_format));
+      $this->assertSession()->responseContains($start_date->format($date_format));
       $this->assertSession()->responseNotContains($start_date->format($time_format));
-      $this->assertRaw($end_date->format($date_format));
+      $this->assertSession()->responseContains($end_date->format($date_format));
       $this->assertSession()->responseNotContains($end_date->format($time_format));
 
       // Verify the date doesn't change when entity is edited through the form.
@@ -326,10 +326,10 @@ public function testDatetimeRangeField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-    $this->assertRaw($start_date->format($date_format));
-    $this->assertRaw($start_date->format($time_format));
-    $this->assertRaw($end_date->format($date_format));
-    $this->assertRaw($end_date->format($time_format));
+    $this->assertSession()->responseContains($start_date->format($date_format));
+    $this->assertSession()->responseContains($start_date->format($time_format));
+    $this->assertSession()->responseContains($end_date->format($date_format));
+    $this->assertSession()->responseContains($end_date->format($time_format));
 
     /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
     $display_repository = \Drupal::service('entity_display.repository');
@@ -499,9 +499,9 @@ public function testAlldayRangeField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-    $this->assertRaw($start_date->format($date_format));
+    $this->assertSession()->responseContains($start_date->format($date_format));
     $this->assertSession()->responseNotContains($start_date->format($time_format));
-    $this->assertRaw($end_date->format($date_format));
+    $this->assertSession()->responseContains($end_date->format($date_format));
     $this->assertSession()->responseNotContains($end_date->format($time_format));
 
     /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php
index 95070c9a037ada590efe977a6b95e3a0c250a47d..b582efc556f5c4b57f2a5c0dddd68c23b76ce6a7 100644
--- a/core/modules/dblog/tests/src/Functional/DbLogTest.php
+++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php
@@ -133,10 +133,10 @@ public function testLogEventPage() {
     $this->assertSession()->linkByHrefExists($context['referer']);
 
     // Verify hostname.
-    $this->assertRaw($context['ip']);
+    $this->assertSession()->pageTextContains($context['ip']);
 
     // Verify location.
-    $this->assertRaw($context['request_uri']);
+    $this->assertSession()->pageTextContains($context['request_uri']);
 
     // Verify severity.
     $this->assertSession()->pageTextContains('Notice');
@@ -402,7 +402,7 @@ private function verifyLinkEscaping() {
     $this->drupalGet('admin/reports/dblog/event/' . $result->fetchField());
 
     // Check if the link exists (unescaped).
-    $this->assertRaw($link);
+    $this->assertSession()->responseContains($link);
   }
 
   /**
@@ -850,7 +850,7 @@ public function testOverviewLinks() {
     $this->drupalGet('admin/reports/dblog');
     $this->assertSession()->statusCodeEquals(200);
     // Make sure HTML tags are filtered out.
-    $this->assertRaw('title="alert(&#039;foo&#039;);Lorem');
+    $this->assertSession()->responseContains('title="alert(&#039;foo&#039;);Lorem');
     $this->assertSession()->responseNotContains("<script>alert('foo');</script>");
 
     // Make sure HTML tags are filtered out in admin/reports/dblog/event/ too.
@@ -860,7 +860,7 @@ public function testOverviewLinks() {
     $wid = $query->execute()->fetchField();
     $this->drupalGet('admin/reports/dblog/event/' . $wid);
     $this->assertSession()->responseNotContains("<script>alert('foo');</script>");
-    $this->assertRaw("alert('foo'); <strong>Lorem ipsum</strong>");
+    $this->assertSession()->responseContains("alert('foo'); <strong>Lorem ipsum</strong>");
   }
 
   /**
@@ -903,8 +903,8 @@ public function testBacktrace() {
     // Check if the full message displays on the details page and backtrace is a
     // pre-formatted text.
     $message = new FormattableMarkup('%type: @message in %function (line', $error_user_notice);
-    $this->assertRaw($message);
-    $this->assertRaw('<pre class="backtrace">');
+    $this->assertSession()->responseContains($message);
+    $this->assertSession()->responseContains('<pre class="backtrace">');
   }
 
 }
diff --git a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
index fcf640f67e421a0eb4a6348a22456844ca8715ec..3574e3bd9ca5c7f7f0d124ccd6386f71d6155077 100644
--- a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
+++ b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php
@@ -81,10 +81,10 @@ public function testDynamicPageCache() {
     foreach (['llama', 'piggy', 'unicorn', 'kitten'] as $animal) {
       $url = Url::fromUri('route:dynamic_page_cache_test.html.with_cache_contexts', ['query' => ['animal' => $animal]]);
       $this->drupalGet($url);
-      $this->assertRaw($animal);
+      $this->assertSession()->pageTextContains($animal);
       $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
       $this->drupalGet($url);
-      $this->assertRaw($animal);
+      $this->assertSession()->pageTextContains($animal);
       $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
 
       // Finally, let's also verify that the 'dynamic_page_cache_test.html'
diff --git a/core/modules/editor/tests/src/Functional/EditorAdminTest.php b/core/modules/editor/tests/src/Functional/EditorAdminTest.php
index 4aa07e3320045f4312ecd80e730168c0d8e47f00..e8b278806b30b3c8e8cf58f7db8fbdc9ab00a6b4 100644
--- a/core/modules/editor/tests/src/Functional/EditorAdminTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorAdminTest.php
@@ -71,7 +71,7 @@ public function testNoEditorAvailable() {
     $options = $select->findAll('css', 'option');
     $this->assertCount(1, $options);
     $this->assertSame('None', $options[0]->getText(), 'Option 1 in the Text Editor select is "None".');
-    $this->assertRaw('This option is disabled because no modules that provide a text editor are currently enabled.');
+    $this->assertSession()->pageTextContains('This option is disabled because no modules that provide a text editor are currently enabled.');
   }
 
   /**
@@ -143,14 +143,14 @@ public function testDisableFormatWithEditor() {
 
     // Go to node edit form.
     $this->drupalGet('node/' . $node->id() . '/edit');
-    $this->assertRaw($text);
+    $this->assertSession()->responseContains($text);
 
     // Disable the format assigned to the 'body' field of the node.
     FilterFormat::load('monoceros')->disable()->save();
 
     // Edit again the node.
     $this->drupalGet('node/' . $node->id() . '/edit');
-    $this->assertRaw($text);
+    $this->assertSession()->responseContains($text);
   }
 
   /**
diff --git a/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php b/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
index bc768e1327b5a03069938b0d5e0a111b1cf41d8f..76a398d622b35cbcfe13dcb146f196c6c6ce60ce 100644
--- a/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\editor\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\editor\Entity\Editor;
 use Drupal\filter\Entity\FilterFormat;
 use Drupal\Tests\BrowserTestBase;
@@ -102,7 +101,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEquals($max_width, $uploaded_image_file_width);
     $this->assertEquals($uploaded_image_file_height * ($uploaded_image_file_width / $max_width), $uploaded_image_file_height);
-    $this->assertRaw((string) new FormattableMarkup('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', ['%dimensions' => $max_width . 'x' . $max_height]));
+    $this->assertSession()->pageTextContains("The image was resized to fit within the maximum allowed dimensions of {$max_width}x{$max_height} pixels.");
 
     // Case 3: max height smaller than uploaded image: image scaled down.
     $test_image = $testing_image_list[2];
@@ -114,7 +113,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEquals($uploaded_image_file_width * ($uploaded_image_file_height / $max_height), $uploaded_image_file_width);
     $this->assertEquals($max_height, $uploaded_image_file_height);
-    $this->assertRaw((string) new FormattableMarkup('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', ['%dimensions' => $max_width . 'x' . $max_height]));
+    $this->assertSession()->pageTextContains("The image was resized to fit within the maximum allowed dimensions of {$max_width}x{$max_height} pixels.");
 
     // Case 4: max dimensions greater than uploaded image: image not scaled.
     $test_image = $testing_image_list[3];
@@ -139,7 +138,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEquals($max_width, $uploaded_image_file_width);
     $this->assertEquals($uploaded_image_file_height * ($uploaded_image_file_width / $max_width), $uploaded_image_file_height);
-    $this->assertRaw((string) new FormattableMarkup('The image was resized to fit within the maximum allowed width of %width pixels.', ['%width' => $max_width]));
+    $this->assertSession()->pageTextContains("The image was resized to fit within the maximum allowed width of {$max_width} pixels.");
 
     // Case 6: only max height dimension was provided and it was smaller than
     // uploaded image: image scaled down.
@@ -152,7 +151,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEquals($uploaded_image_file_width * ($uploaded_image_file_height / $max_height), $uploaded_image_file_width);
     $this->assertEquals($max_height, $uploaded_image_file_height);
-    $this->assertRaw((string) new FormattableMarkup('The image was resized to fit within the maximum allowed height of %height pixels.', ['%height' => $max_height]));
+    $this->assertSession()->pageTextContains("The image was resized to fit within the maximum allowed height of {$max_height} pixels.");
   }
 
   /**
diff --git a/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
index 822922322b6ecad7111d20f1c2c9fecd5e25b7f7..5f9baaa1e4de8c37051a4e53cfcdb7eb214b5cb0 100644
--- a/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
+++ b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
@@ -87,7 +87,7 @@ public function testUsersWithoutPermission() {
       $this->drupalGet('node/1');
 
       // Ensure the text is transformed.
-      $this->assertRaw('<p>Do you also love Drupal?</p><figure role="group" class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
+      $this->assertSession()->responseContains('<p>Do you also love Drupal?</p><figure role="group" class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
 
       $client = $this->getHttpClient();
 
@@ -125,7 +125,7 @@ public function testUserWithPermission() {
     $this->drupalGet('node/1');
 
     // Ensure the text is transformed.
-    $this->assertRaw('<p>Do you also love Drupal?</p><figure role="group" class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
+    $this->assertSession()->responseContains('<p>Do you also love Drupal?</p><figure role="group" class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
     $client = $this->getHttpClient();
     $response = $client->post($this->buildUrl('editor/node/1/body/en/full'), [
       'query' => http_build_query([MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']),
diff --git a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php
index fb431349b85974f62afb5b7ddb7838d4c9e5f297..136ce8b923e5b0f079ce6640e30adbc64fc7f62d 100644
--- a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php
+++ b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php
@@ -122,7 +122,7 @@ public function testBooleanField() {
     // Verify that boolean value is displayed.
     $entity = EntityTest::load($id);
     $this->drupalGet($entity->toUrl());
-    $this->assertRaw('<div class="field__item">' . $on . '</div>');
+    $this->assertSession()->responseContains('<div class="field__item">' . $on . '</div>');
 
     // Test with "On" label option.
     $display_repository->getFormDisplay('entity_test', 'entity_test')
@@ -136,7 +136,7 @@ public function testBooleanField() {
 
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[value]", '');
-    $this->assertRaw($on);
+    $this->assertSession()->pageTextContains($on);
     $this->assertSession()->pageTextNotContains($this->field->label());
 
     // Test if we can change the on label.
@@ -148,7 +148,7 @@ public function testBooleanField() {
     $this->submitForm($edit, 'Save settings');
     // Check if we see the updated labels in the creation form.
     $this->drupalGet('entity_test/add');
-    $this->assertRaw($on);
+    $this->assertSession()->pageTextContains($on);
 
     // Go to the form display page and check if the default settings works as
     // expected.
diff --git a/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php b/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php
index 09ad6ff2481197374539fabfb7ec0884e3319681..31bf7daa97e4c973ccf4bde75216944e1b6a9f0f 100644
--- a/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php
+++ b/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php
@@ -90,7 +90,7 @@ public function testEmailField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
-    $this->assertRaw('placeholder="example@example.com"');
+    $this->assertSession()->responseContains('placeholder="example@example.com"');
 
     // Submit a valid email address and ensure it is accepted.
     $value = 'test@example.com';
@@ -101,7 +101,7 @@ public function testEmailField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-    $this->assertRaw($value);
+    $this->assertSession()->responseContains($value);
 
     // Verify that a mailto link is displayed.
     $entity = EntityTest::load($id);
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
index 7877ce87b56d772269f74221368d14ba26cc092a..a9b551084e8a2f9fa077a85700085f9cdf585845 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
@@ -156,8 +156,8 @@ public function testFieldAdminHandler() {
     $this->assertStringContainsString("/entity_reference_autocomplete/node/views/", $field->getAttribute('data-autocomplete-path'));
     $target_url = $this->getAbsoluteUrl($field->getAttribute('data-autocomplete-path'));
     $this->drupalGet($target_url, ['query' => ['q' => 'Foo']]);
-    $this->assertRaw($node1->getTitle() . ' (' . $node1->id() . ')');
-    $this->assertRaw($node2->getTitle() . ' (' . $node2->id() . ')');
+    $this->assertSession()->pageTextContains($node1->getTitle() . ' (' . $node1->id() . ')');
+    $this->assertSession()->pageTextContains($node2->getTitle() . ' (' . $node2->id() . ')');
 
     // Try to add a new node, fill the entity reference field and submit the
     // form.
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
index 0b064554d4a7bec7a67f8826b4f071a9c18babb3..ec7c7b13217c65294b4cfca540f59d3daec46343 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
@@ -91,7 +91,7 @@ public function testEntityReferenceDefaultValue() {
 
     // Check that default value is selected in default value form.
     $this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name);
-    $this->assertRaw('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')');
+    $this->assertSession()->responseContains('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')');
 
     // Check if the ID has been converted to UUID in config entity.
     $config_entity = $this->config('field.field.node.reference_content.' . $field_name)->get();
diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
index 576510d9c67f9b4ba4879614c255917abbbd06e4..595aba8e22c801a39d23f39b6c14a5438327a3bf 100644
--- a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
+++ b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
@@ -76,7 +76,7 @@ public function testNumberDecimalField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
-    $this->assertRaw('placeholder="0.00"');
+    $this->assertSession()->responseContains('placeholder="0.00"');
 
     // Submit a signed decimal value within the allowed precision and scale.
     $value = '-1234.5678';
@@ -87,7 +87,7 @@ public function testNumberDecimalField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-    $this->assertRaw($value);
+    $this->assertSession()->responseContains($value);
 
     // Try to create entries with more than one decimal separator; assert fail.
     $wrong_entries = [
@@ -191,7 +191,7 @@ public function testNumberIntegerField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
-    $this->assertRaw('placeholder="4"');
+    $this->assertSession()->responseContains('placeholder="4"');
 
     // Submit a valid integer
     $value = rand($minimum, $maximum);
@@ -251,7 +251,7 @@ public function testNumberIntegerField() {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-      $this->assertRaw($valid_entry);
+      $this->assertSession()->responseContains($valid_entry);
       // Verify that the "content" attribute is not present since the Prefix is
       // not being displayed.
       $this->assertSession()->elementNotExists('xpath', '//div[@content="' . $valid_entry . '"]');
@@ -320,7 +320,7 @@ public function testNumberFloatField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
-    $this->assertRaw('placeholder="0.00"');
+    $this->assertSession()->responseContains('placeholder="0.00"');
 
     // Submit a signed decimal value within the allowed precision and scale.
     $value = '-1234.5678';
@@ -335,7 +335,7 @@ public function testNumberFloatField() {
     // Ensure that the 'number_decimal' formatter displays the number with the
     // expected rounding.
     $this->drupalGet('entity_test/' . $id);
-    $this->assertRaw(round($value, 2));
+    $this->assertSession()->responseContains(round($value, 2));
 
     // Try to create entries with more than one decimal separator; assert fail.
     $wrong_entries = [
diff --git a/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php b/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php
index 7c30d465e5fd11c040569b845b55a1e80c0a9248..2e1b17cc9bb51ce63f3e8670d2a75a33c19553c5 100644
--- a/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php
+++ b/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php
@@ -92,7 +92,7 @@ public function testReEnabledField() {
       'field_telephone[0][value]' => "123456789",
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw('<a href="tel:123456789">');
+    $this->assertSession()->responseContains('<a href="tel:123456789">');
 
     // Test that the module can't be uninstalled from the UI while there is data
     // for its fields.
diff --git a/core/modules/field/tests/src/Functional/String/StringFieldTest.php b/core/modules/field/tests/src/Functional/String/StringFieldTest.php
index a8140c4ad42e4fbe92a378eab9931fbe3c52a5ea..295169d4d2f0bd62571272562d8db4184142c125 100644
--- a/core/modules/field/tests/src/Functional/String/StringFieldTest.php
+++ b/core/modules/field/tests/src/Functional/String/StringFieldTest.php
@@ -92,7 +92,7 @@ public function _testTextfieldWidgets($field_type, $widget_type) {
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
     $this->assertSession()->fieldNotExists("{$field_name}[0][format]");
-    $this->assertRaw(new FormattableMarkup('placeholder="A placeholder on @widget_type"', ['@widget_type' => $widget_type]));
+    $this->assertSession()->responseContains(new FormattableMarkup('placeholder="A placeholder on @widget_type"', ['@widget_type' => $widget_type]));
 
     // Submit with some value.
     $value = $this->randomMachineName();
diff --git a/core/modules/field/tests/src/FunctionalJavascript/Number/NumberFieldTest.php b/core/modules/field/tests/src/FunctionalJavascript/Number/NumberFieldTest.php
index 013182f08d9ace7f534215eb9edb5a19904a5d5e..78a565d0f81d79bc20cdc87ecbabff8beee9a9a0 100644
--- a/core/modules/field/tests/src/FunctionalJavascript/Number/NumberFieldTest.php
+++ b/core/modules/field/tests/src/FunctionalJavascript/Number/NumberFieldTest.php
@@ -151,8 +151,8 @@ public function testNumberFormatter() {
     // Check number_decimal and number_unformatted formatters behavior.
     $this->drupalGet('node/' . $node->id());
     $float_formatted = number_format($random_float, $scale, $decimal_separator, $thousand_separator);
-    $this->assertRaw("$prefix$float_formatted$suffix");
-    $this->assertRaw((string) $random_integer);
+    $this->assertSession()->responseContains("$prefix$float_formatted$suffix");
+    $this->assertSession()->responseContains((string) $random_integer);
 
     // Configure the number_decimal formatter.
     \Drupal::service('entity_display.repository')->getViewDisplay('node', $type)
@@ -182,7 +182,7 @@ public function testNumberFormatter() {
     $this->drupalGet('node/' . $node->id());
 
     $integer_formatted = number_format($random_integer, 0, '', $thousand_separator);
-    $this->assertRaw($integer_formatted);
+    $this->assertSession()->responseContains($integer_formatted);
   }
 
 }
diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
index 155190988b5d07a8b790ed2280dbab9f6ed4490f..fea239374b6f2cf97691f9cb77eeedc57aeb1d74 100644
--- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
+++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php
@@ -69,7 +69,7 @@ public function testEntityViewModeUI() {
       'label' => $this->randomString(),
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+    $this->assertSession()->pageTextContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
 
     // Test adding a view mode.
     $edit = [
@@ -123,7 +123,7 @@ public function testEntityFormModeUI() {
       'label' => $this->randomString(),
     ];
     $this->submitForm($edit, 'Save');
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+    $this->assertSession()->pageTextContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
 
     // Test adding a form mode.
     $edit = [
diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
index 68813e4530c99259fa6046c3c7b5b3b470aa3bb6..f9a1756bffc9f9ff7177d3c9054a7833d16083e9 100644
--- a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
+++ b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
@@ -44,7 +44,7 @@ protected function setUp(): void {
 
   public function testIndentation() {
     $this->drupalGet('admin/structure/types/manage/page/display');
-    $this->assertRaw('js-indentation indentation');
+    $this->assertSession()->responseContains('js-indentation indentation');
   }
 
 }
diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
index b99e51f25f725f83c49a25d6fd8b0c95724dde68..17fca561265b2ea43c9cade7158ebd964401d9c4 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
@@ -173,7 +173,7 @@ public function manageFieldsPage($type = '') {
     ];
     foreach ($table_headers as $table_header) {
       // We check that the label appear in the table headings.
-      $this->assertRaw($table_header . '</th>');
+      $this->assertSession()->responseContains($table_header . '</th>');
     }
 
     // Test the "Add field" action link.
@@ -750,7 +750,7 @@ public function testExternalDestinations() {
     // The external redirect should not fire.
     $this->assertSession()->addressEquals('admin/structure/types/manage/article/fields/node.article.body/storage?destinations%5B0%5D=http%3A//example.com');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
+    $this->assertSession()->responseContains('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
   }
 
   /**
@@ -812,8 +812,8 @@ public function testHelpDescriptions() {
     $this->submitForm($edit, 'Save settings');
 
     $this->drupalGet('node/add/article');
-    $this->assertRaw('<strong>Test with an upload field.</strong>');
-    $this->assertRaw('<em>Test with a non upload field.</em>');
+    $this->assertSession()->responseContains('<strong>Test with an upload field.</strong>');
+    $this->assertSession()->responseContains('<em>Test with a non upload field.</em>');
   }
 
   /**
diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
index d1e4ee39de2808934f5bfea5dafaf70bad39fe2d..000daddb3ffc614f67f323e5eb99c544704403e6 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
@@ -93,7 +93,7 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
     $this->submitForm($initial_edit, 'Save and continue');
     // Set the main content to only the content region because the label can
     // contain HTML which will be auto-escaped by Twig.
-    $this->assertRaw('field-config-edit-form');
+    $this->assertSession()->responseContains('field-config-edit-form');
     // Check that the page does not have double escaped HTML tags.
     $this->assertSession()->responseNotContains('&amp;lt;');
 
diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php
index b56afa1cec0e92cd5314a209e8469c48e6adea44..0a2fdb9ba42cb863bccdeed19641d4ffdb51228d 100644
--- a/core/modules/file/tests/src/Functional/DownloadTest.php
+++ b/core/modules/file/tests/src/Functional/DownloadTest.php
@@ -187,7 +187,7 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) {
 
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(file_get_contents($file->getFileUri()));
+    $this->assertSession()->responseContains(file_get_contents($file->getFileUri()));
 
     $file->delete();
   }
diff --git a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
index 6628e2b663a8ecb25d34889f7059692ae3d233e4..3e342dae4ce90f28ae2c186480fa056b90888e50 100644
--- a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
@@ -80,7 +80,7 @@ public function testNodeDisplay() {
       '#file' => $node_file,
     ];
     $default_output = \Drupal::service('renderer')->renderRoot($file_link);
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     // Turn the "display" option off and check that the file is no longer displayed.
     $edit = [$field_name . '[0][display]' => FALSE];
@@ -100,7 +100,7 @@ public function testNodeDisplay() {
     $this->assertSession()->pageTextContains($description);
 
     // Ensure the filename in the link's title attribute is escaped.
-    $this->assertRaw('title="escaped-&amp;-text.txt"');
+    $this->assertSession()->responseContains('title="escaped-&amp;-text.txt"');
 
     // Test that fields appear as expected after during the preview.
     // Add a second file.
@@ -115,9 +115,9 @@ public function testNodeDisplay() {
     $this->submitForm($edit, 'Preview');
     $this->clickLink('Back to content editing');
     // First file.
-    $this->assertRaw($field_name . '[0][display]');
+    $this->assertSession()->responseContains($field_name . '[0][display]');
     // Second file.
-    $this->assertRaw($field_name . '[1][display]');
+    $this->assertSession()->responseContains($field_name . '[1][display]');
     $this->assertSession()->responseContains($field_name . '[1][description]');
 
     // Check that the file fields don't contain duplicate HTML IDs.
diff --git a/core/modules/file/tests/src/Functional/FileListingTest.php b/core/modules/file/tests/src/Functional/FileListingTest.php
index ee645eaf1c750f67cd037f24a95513e54b2da1bf..182c4713ece087a20249e5aed6d65a2588a16993 100644
--- a/core/modules/file/tests/src/Functional/FileListingTest.php
+++ b/core/modules/file/tests/src/Functional/FileListingTest.php
@@ -131,11 +131,11 @@ public function testFileListingPages() {
     $this->drupalGet('admin/content/files');
     $file = File::load($orphaned_file);
     $usage = $this->sumUsages($file_usage->listUsage($file));
-    $this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage);
+    $this->assertSession()->responseContains('admin/content/files/usage/' . $file->id() . '">' . $usage);
 
     $file = File::load($used_file);
     $usage = $this->sumUsages($file_usage->listUsage($file));
-    $this->assertRaw('admin/content/files/usage/' . $file->id() . '">' . $usage);
+    $this->assertSession()->responseContains('admin/content/files/usage/' . $file->id() . '">' . $usage);
 
     $result = $this->xpath("//td[contains(@class, 'views-field-status') and contains(text(), :value)]", [':value' => 'Temporary']);
     $this->assertCount(1, $result, 'Unused file marked as temporary.');
diff --git a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
index c23d199c3a6e20cd48605a4ab9b065c55a11ba13..36f2d1e782d2efc2b528be8a7b498c9b04bfe9fe 100644
--- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
+++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
@@ -161,7 +161,7 @@ public function testManagedFileRemoved() {
     $this->submitForm($edit, 'Upload');
     // We expect the title 'Managed <em>file & butter</em>' which got escaped
     // via a t() call before.
-    $this->assertRaw('The file referenced by the Managed <em>file &amp; butter</em> field does not exist.');
+    $this->assertSession()->responseContains('The file referenced by the Managed <em>file &amp; butter</em> field does not exist.');
   }
 
   /**
diff --git a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
index 0424dc8286652597917f631ad2c1ae1af9fa74d1..cce9408ceb101d6bbd3ff6f86bcfc4c9802dcec4 100644
--- a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
+++ b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
@@ -115,7 +115,7 @@ public function testSyncedFiles() {
     $this->submitForm($edit, 'Save (this translation)');
     // This inspects the HTML after the post of the translation, the file
     // should be displayed on the original node.
-    $this->assertRaw('file--mime-text-plain');
+    $this->assertSession()->responseContains('file--mime-text-plain');
     $second_fid = $this->getLastFileId();
 
     \Drupal::entityTypeManager()->getStorage('file')->resetCache();
@@ -149,7 +149,7 @@ public function testSyncedFiles() {
     $this->assertTrue($file->isPermanent(), 'First file still exists and is permanent.');
     // This inspects the HTML after the post of the translation, the file
     // should be displayed on the original node.
-    $this->assertRaw('file--mime-text-plain');
+    $this->assertSession()->responseContains('file--mime-text-plain');
 
     // Ensure the file status of the second file is permanent.
     $file = File::load($second_fid);
diff --git a/core/modules/file/tests/src/Functional/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php
index e7f8cdfc65508a7142de0ee7e1de3c9a76980b97..8d82b2fb34bb30722c56e40a076dd4bd628228dc 100644
--- a/core/modules/file/tests/src/Functional/FilePrivateTest.php
+++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php
@@ -55,7 +55,7 @@ public function testPrivateFile() {
     $node_file = File::load($node->{$field_name}->target_id);
     // Ensure the file can be viewed.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw($node_file->getFilename());
+    $this->assertSession()->responseContains($node_file->getFilename());
     // Ensure the file can be downloaded.
     $this->drupalGet($node_file->createFileUrl(FALSE));
     $this->assertSession()->statusCodeEquals(200);
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index 6f101f21a891d741b84571988eb086ab5deee23d..eca962ae0190ddfbd831d297af6fd6a95fdfc9e5 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -505,8 +505,8 @@ public function testErrorMessagesAreNotChanged() {
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
     $this->assertSession()->pageTextContains($error);
-    $this->assertRaw('Number of error messages before _file_save_upload_from_form(): 1');
-    $this->assertRaw('Number of error messages after _file_save_upload_from_form(): 1');
+    $this->assertSession()->pageTextContains('Number of error messages before _file_save_upload_from_form(): 1');
+    $this->assertSession()->pageTextContains('Number of error messages after _file_save_upload_from_form(): 1');
 
     // Test that error messages are preserved when an error occurs.
     $edit = [
@@ -522,8 +522,8 @@ public function testErrorMessagesAreNotChanged() {
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
     $this->assertSession()->pageTextContains($error);
-    $this->assertRaw('Number of error messages before _file_save_upload_from_form(): 1');
-    $this->assertRaw('Number of error messages after _file_save_upload_from_form(): 1');
+    $this->assertSession()->pageTextContains('Number of error messages before _file_save_upload_from_form(): 1');
+    $this->assertSession()->pageTextContains('Number of error messages after _file_save_upload_from_form(): 1');
 
     // Test a successful upload with no messages.
     $edit = [
@@ -537,8 +537,8 @@ public function testErrorMessagesAreNotChanged() {
     // Ensure the error message is not present and the counts before and after
     // calling _file_save_upload_from_form() are correct.
     $this->assertSession()->pageTextNotContains($error);
-    $this->assertRaw('Number of error messages before _file_save_upload_from_form(): 0');
-    $this->assertRaw('Number of error messages after _file_save_upload_from_form(): 0');
+    $this->assertSession()->pageTextContains('Number of error messages before _file_save_upload_from_form(): 0');
+    $this->assertSession()->pageTextContains('Number of error messages after _file_save_upload_from_form(): 0');
   }
 
   /**
diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
index b4a2bce29c5685b62d735219650749e0430dcaf0..d19a933659ed6a521617f870a0ea171c880276c1 100644
--- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
@@ -303,7 +303,7 @@ public function testFilterAdmin() {
     $this->drupalLogin($this->webUser);
 
     $this->drupalGet('node/add/page');
-    $this->assertRaw('<option value="' . $full . '">Full HTML</option>');
+    $this->assertSession()->responseContains('<option value="' . $full . '">Full HTML</option>');
 
     // Use basic HTML and see if it removes tags that are not allowed.
     $body = '<em>' . $this->randomMachineName() . '</em>';
@@ -326,7 +326,7 @@ public function testFilterAdmin() {
 
     $this->drupalGet('node/' . $node->id());
     // Check that filter removed invalid tag.
-    $this->assertRaw($body . $extra_text);
+    $this->assertSession()->responseContains($body . $extra_text);
 
     // Use plain text and see if it escapes all tags, whether allowed or not.
     // In order to test plain text, we have to enable the hidden variable for
@@ -411,10 +411,10 @@ public function testFilterTipHtmlEscape() {
 
     $this->drupalGet('filter/tips');
 
-    $this->assertRaw('<td class="type">' . $link_as_code . '</td>');
-    $this->assertRaw('<td class="get">' . $link . '</td>');
-    $this->assertRaw('<td class="type">' . $ampersand_as_code . '</td>');
-    $this->assertRaw('<td class="get">' . $ampersand . '</td>');
+    $this->assertSession()->responseContains('<td class="type">' . $link_as_code . '</td>');
+    $this->assertSession()->responseContains('<td class="get">' . $link . '</td>');
+    $this->assertSession()->responseContains('<td class="type">' . $ampersand_as_code . '</td>');
+    $this->assertSession()->responseContains('<td class="get">' . $ampersand . '</td>');
   }
 
   /**
@@ -464,7 +464,7 @@ public function testDisabledFormat() {
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/reports/dblog');
     // The correct message has been logged.
-    $this->assertRaw(sprintf('Disabled text format: %s.', $format_id));
+    $this->assertSession()->pageTextContains(sprintf('Disabled text format: %s.', $format_id));
 
     // Programmatically change the text format to something random so we trigger
     // the missing text format message.
@@ -479,7 +479,7 @@ public function testDisabledFormat() {
     // Visit the dblog report page.
     $this->drupalGet('admin/reports/dblog');
     // The missing text format message has been logged.
-    $this->assertRaw(sprintf('Missing text format: %s.', $format_id));
+    $this->assertSession()->pageTextContains(sprintf('Missing text format: %s.', $format_id));
   }
 
 }
diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php
index 68c380efda5106eaea773d100d0c68f9112bcd6a..8480ab6706d5ed239bfb0c4c795713c53c058394 100644
--- a/core/modules/forum/tests/src/Functional/ForumTest.php
+++ b/core/modules/forum/tests/src/Functional/ForumTest.php
@@ -135,7 +135,7 @@ public function testForum() {
     // Check that the basic forum install creates a default forum topic
     $this->drupalGet('/forum');
     // Look for the "General discussion" default forum
-    $this->assertRaw(Link::createFromRoute(t('General discussion'), 'forum.page', ['taxonomy_term' => 1])->toString());
+    $this->assertSession()->responseContains(Link::createFromRoute(t('General discussion'), 'forum.page', ['taxonomy_term' => 1])->toString());
     // Check the presence of expected cache tags.
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:forum.settings');
 
@@ -332,13 +332,13 @@ private function doAdminTests($user) {
     $this->assertSession()->linkExists('Add forum');
     $this->assertSession()->linkExists('Add container');
     $this->clickLink('edit container');
-    $this->assertRaw('Edit container');
+    $this->assertSession()->pageTextContains('Edit container');
     // Create forum inside the forum container.
     $this->forum = $this->createForum('forum', $this->forumContainer['tid']);
     // Verify the "edit forum" link exists and functions correctly.
     $this->drupalGet('admin/structure/forum');
     $this->clickLink('edit forum');
-    $this->assertRaw('Edit forum');
+    $this->assertSession()->pageTextContains('Edit forum');
     // Navigate back to forum structure page.
     $this->drupalGet('admin/structure/forum');
     // Create second forum in container, destined to be deleted below.
@@ -604,8 +604,8 @@ public function createForumTopic($forum, $container = FALSE) {
 
     // View forum topic.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw($title);
-    $this->assertRaw($body);
+    $this->assertSession()->pageTextContains($title);
+    $this->assertSession()->pageTextContains($body);
 
     return $node;
   }
@@ -652,7 +652,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) {
       '#theme' => 'breadcrumb',
       '#links' => $breadcrumb_build,
     ];
-    $this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb));
+    $this->assertSession()->responseContains(\Drupal::service('renderer')->renderRoot($breadcrumb));
 
     // View forum edit node.
     $this->drupalGet('node/' . $node->id() . '/edit');
@@ -718,7 +718,7 @@ private function verifyForumView($forum, $parent = NULL) {
       '#theme' => 'breadcrumb',
       '#links' => $breadcrumb_build,
     ];
-    $this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb));
+    $this->assertSession()->responseContains(\Drupal::service('renderer')->renderRoot($breadcrumb));
   }
 
   /**
diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
index cb597b7ff1837857b643dcaa65bc92cf6b7258b7..0f3fa8a910d0ada81225fc16b2caacd3efdadf4c 100644
--- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
@@ -494,7 +494,7 @@ public function testConfigImport() {
 
     // Test that image is displayed using newly created style.
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw(\Drupal::service('file_url_generator')->transformRelative($style->buildUrl($original_uri)));
+    $this->assertSession()->responseContains(\Drupal::service('file_url_generator')->transformRelative($style->buildUrl($original_uri)));
 
     // Copy config to sync, and delete the image style.
     $sync = $this->container->get('config.storage.sync');
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
index 7cc89b1af83e211b2420fb0e72392b878cfa5fbc..3acf4fa263ee6a84a1a8a26af19d19f30735d6b8 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
@@ -200,7 +200,7 @@ public function testDefaultImages() {
     // Confirm the default image is shown on the node form.
     $file = File::load($default_images['field_new']->id());
     $this->drupalGet('node/add/article');
-    $this->assertRaw($file->getFilename());
+    $this->assertSession()->responseContains($file->getFilename());
 
     // Remove the field default from articles.
     $default_image_settings = $field->getSetting('default_image');
@@ -229,7 +229,7 @@ public function testDefaultImages() {
     // Confirm the default image is shown on the node form.
     $file = File::load($default_images['field_storage_new']->id());
     $this->drupalGet('node/add/article');
-    $this->assertRaw($file->getFilename());
+    $this->assertSession()->responseContains($file->getFilename());
 
     // Change the default image for the field storage and also change the upload
     // destination to the private filesystem at the same time.
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
index f76f6fcfb5524f4363de428a48cb7ca66f8c1071..4964908cfc1543fd378fe80ba8e4396330dde370 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
@@ -117,7 +117,7 @@ public function _testImageFieldFormatters($scheme) {
       '#alt' => $alt,
     ];
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     // Test the image linked to file formatter.
     $display_options = [
@@ -143,7 +143,7 @@ public function _testImageFieldFormatters($scheme) {
     $this->assertCacheContext('url.site');
     // Verify that no image style cache tags are found.
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
     // Verify that the image can be downloaded.
     $this->assertEquals(file_get_contents($test_image->uri), $this->drupalGet($file->createFileUrl(FALSE)), 'File was downloaded successfully.');
     if ($scheme == 'private') {
@@ -208,7 +208,7 @@ public function _testImageFieldFormatters($scheme) {
     $this->drupalGet('node/' . $nid);
     $image_style = ImageStyle::load('thumbnail');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $image_style->getCacheTags()[0]);
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     if ($scheme == 'private') {
       // Log out and ensure the file cannot be accessed.
@@ -306,7 +306,7 @@ public function testImageFieldSettings() {
     $this->drupalGet('node/' . $nid . '/edit');
     $this->submitForm($edit, 'Save');
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     // Verify that alt/title longer than allowed results in a validation error.
     $test_size = 2000;
@@ -403,7 +403,7 @@ public function testImageFieldDefaultImage() {
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]);
     // Verify that no image style cache tags are found.
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     // Create a node with an image attached and ensure that the default image
     // is not displayed.
@@ -431,7 +431,7 @@ public function testImageFieldDefaultImage() {
     // Default image should not be displayed.
     $this->assertSession()->responseNotContains($default_output);
     // User supplied image should be displayed.
-    $this->assertRaw($image_output);
+    $this->assertSession()->responseContains($image_output);
 
     // Remove default image from the field and make sure it is no longer used.
     // Can't use fillField cause Mink can't fill hidden fields.
@@ -484,7 +484,7 @@ public function testImageFieldDefaultImage() {
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:');
     // Default private image should be displayed when no user supplied image
     // is present.
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
   }
 
 }
diff --git a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
index ec2f6890e0f9a48bc5a0c8bcdb14aee20fc07f26..64d2f92c74774b1c9160a0f87a64c05862306c36 100644
--- a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
+++ b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
@@ -130,12 +130,12 @@ public function testSyncedImages() {
     $this->submitForm($edit, 'Save (this translation)');
     // This inspects the HTML after the post of the translation, the image
     // should be displayed on the original node.
-    $this->assertRaw('alt="Lost in translation image"');
-    $this->assertRaw('title="Lost in translation image title"');
+    $this->assertSession()->responseContains('alt="Lost in translation image"');
+    $this->assertSession()->responseContains('title="Lost in translation image title"');
     $second_fid = $this->getLastFileId();
     // View the translated node.
     $this->drupalGet('fr/node/' . $default_language_node->id());
-    $this->assertRaw('alt="Scarlett Johansson image"');
+    $this->assertSession()->responseContains('alt="Scarlett Johansson image"');
 
     \Drupal::entityTypeManager()->getStorage('file')->resetCache();
 
@@ -170,12 +170,12 @@ public function testSyncedImages() {
     $this->assertTrue($file->isPermanent(), 'First file still exists and is permanent.');
     // This inspects the HTML after the post of the translation, the image
     // should be displayed on the original node.
-    $this->assertRaw('alt="Lost in translation image"');
-    $this->assertRaw('title="Lost in translation image title"');
+    $this->assertSession()->responseContains('alt="Lost in translation image"');
+    $this->assertSession()->responseContains('title="Lost in translation image title"');
     // View the translated node.
     $this->drupalGet('nl/node/' . $default_language_node->id());
-    $this->assertRaw('alt="Akiko Takeshita image"');
-    $this->assertRaw('title="Akiko Takeshita image title"');
+    $this->assertSession()->responseContains('alt="Akiko Takeshita image"');
+    $this->assertSession()->responseContains('title="Akiko Takeshita image title"');
 
     // Ensure the file status of the second file is permanent.
     $file = File::load($second_fid);
diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php
index 8cc17bfc15977102bb47e75acc71261191c74878..04c0c0831e4b104d2b1450412144fbe0f030f923 100644
--- a/core/modules/language/tests/src/Functional/LanguageListTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageListTest.php
@@ -72,7 +72,7 @@ public function testLanguageList() {
     $this->drupalGet('admin/config/regional/language/add');
     $this->submitForm($edit, 'Add custom language');
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
     $this->assertSession()->pageTextContains($name);
 
     $language = \Drupal::service('language_manager')->getLanguage($langcode);
@@ -106,7 +106,7 @@ public function testLanguageList() {
     ];
     $this->drupalGet('admin/config/regional/language/edit/' . $langcode);
     $this->submitForm($edit, 'Save language');
-    $this->assertRaw($name);
+    $this->assertSession()->pageTextContains($name);
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', [], ['language' => $language]));
 
     // Change back the default language.
@@ -125,7 +125,7 @@ public function testLanguageList() {
     // First test the 'cancel' link.
     $this->clickLink('Cancel');
     $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', [], ['language' => $english]));
-    $this->assertRaw($name);
+    $this->assertSession()->pageTextContains($name);
     // Delete the language for real. This a confirm form, we do not need any
     // fields changed.
     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
index f1f33104a44679e506b98c67565baa1e7ee39658..018ed621f7a36827df74d0635570ebf9493f540c 100644
--- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
@@ -58,7 +58,7 @@ protected function setUp(): void {
 
     // Check that drupalSettings contains path prefix.
     $this->drupalGet('fr/admin/config/regional/language/detection');
-    $this->assertRaw('"pathPrefix":"fr\/"');
+    $this->assertSession()->responseContains('"pathPrefix":"fr\/"');
   }
 
   /**
diff --git a/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php
index 22b03b0c08e5baf9a7e3817b0a24303bc03a811a..2e4044abfa934da65e1f00c9a442638b3d70fcc6 100644
--- a/core/modules/link/tests/src/Functional/LinkFieldTest.php
+++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php
@@ -105,7 +105,7 @@ public function testURLValidation() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertSession()->fieldValueEquals("{$field_name}[0][uri]", '');
-    $this->assertRaw('placeholder="http://example.com"');
+    $this->assertSession()->responseContains('placeholder="http://example.com"');
 
     // Create a path alias.
     $this->createPathAlias('/admin', '/a/path/alias');
@@ -222,7 +222,7 @@ protected function assertValidEntries($field_name, array $valid_entries) {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
-      $this->assertRaw('"' . $string . '"');
+      $this->assertSession()->responseContains('"' . $string . '"');
     }
   }
 
@@ -296,14 +296,14 @@ public function testLinkTitle() {
       // Assert label is shown.
       $this->assertSession()->pageTextContains('Read more about this entity');
       $this->assertSession()->fieldValueEquals("{$field_name}[0][uri]", '');
-      $this->assertRaw('placeholder="http://example.com"');
+      $this->assertSession()->responseContains('placeholder="http://example.com"');
 
       if ($title_setting === DRUPAL_DISABLED) {
         $this->assertSession()->fieldNotExists("{$field_name}[0][title]");
         $this->assertSession()->responseNotContains('placeholder="Enter the text for this link"');
       }
       else {
-        $this->assertRaw('placeholder="Enter the text for this link"');
+        $this->assertSession()->responseContains('placeholder="Enter the text for this link"');
 
         $this->assertSession()->fieldValueEquals("{$field_name}[0][title]", '');
         if ($title_setting === DRUPAL_OPTIONAL) {
diff --git a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php
index 4b90208ec4e6724a8c32fc2c7191aaf005c3250a..ff5de02b91ef610928a47d767850c89253d97376 100644
--- a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php
+++ b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php
@@ -86,17 +86,17 @@ public function testLinkViewsTokens() {
 
     foreach ($uris as $uri => $title) {
       // Formatted link: {{ field_link }}<br />
-      $this->assertRaw("Formatted: <a href=\"$uri\" class=\"test-link-class\">$title</a>");
+      $this->assertSession()->responseContains("Formatted: <a href=\"$uri\" class=\"test-link-class\">$title</a>");
 
       // Raw uri: {{ field_link__uri }}<br />
-      $this->assertRaw("Raw uri: $uri");
+      $this->assertSession()->responseContains("Raw uri: $uri");
 
       // Raw title: {{ field_link__title }}<br />
-      $this->assertRaw("Raw title: $title");
+      $this->assertSession()->responseContains("Raw title: $title");
 
       // Raw options: {{ field_link__options }}<br />
       // Options is an array and should return empty after token replace.
-      $this->assertRaw("Raw options: .");
+      $this->assertSession()->responseContains("Raw options: .");
     }
   }
 
diff --git a/core/modules/locale/tests/src/Functional/LocaleContentTest.php b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
index e0026b825c851bf2399b2067bdd588b7c2c4e153..1f67248703c9cd7fac9c8e5d404556e398722575 100644
--- a/core/modules/locale/tests/src/Functional/LocaleContentTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
@@ -137,7 +137,7 @@ public function testContentTypeLanguageConfiguration() {
     // Edit the content and ensure correct language is selected.
     $path = 'node/' . $node->id() . '/edit';
     $this->drupalGet($path);
-    $this->assertRaw('<option value="' . $langcode . '" selected="selected">' . $name . '</option>');
+    $this->assertSession()->responseContains('<option value="' . $langcode . '" selected="selected">' . $name . '</option>');
     // Ensure we can change the node language.
     $edit = [
       'langcode[0][value]' => 'en',
diff --git a/core/modules/locale/tests/src/Functional/LocaleExportTest.php b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
index 4a6a99114684d234f66e1a5ac245bf7cdd22d933..6eadb93215de3ca2755f5f2d08a38ea119f002b4 100644
--- a/core/modules/locale/tests/src/Functional/LocaleExportTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
@@ -68,9 +68,9 @@ public function testExportTranslation() {
     $this->submitForm(['langcode' => 'fr'], 'Export');
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal');
+    $this->assertSession()->pageTextContains('# French translation of Drupal');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw('msgstr "lundi"');
+    $this->assertSession()->pageTextContains('msgstr "lundi"');
 
     // Import some more French translations which will be marked as customized.
     $name = $file_system->tempnam('temporary://', "po2_") . '.po';
@@ -100,9 +100,9 @@ public function testExportTranslation() {
     ], 'Export');
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal');
+    $this->assertSession()->pageTextContains('# French translation of Drupal');
     // Ensure the customized translations exist in the file.
-    $this->assertRaw('msgstr "janvier"');
+    $this->assertSession()->pageTextContains('msgstr "janvier"');
     // Ensure no untranslated strings exist in the file.
     $this->assertSession()->responseNotContains('msgid "February"');
 
@@ -116,11 +116,11 @@ public function testExportTranslation() {
     ], 'Export');
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal');
+    $this->assertSession()->pageTextContains('# French translation of Drupal');
     // Ensure no customized translations exist in the file.
     $this->assertSession()->responseNotContains('msgstr "janvier"');
     // Ensure the untranslated strings exist in the file, and with right quotes.
-    $this->assertRaw($this->getUntranslatedString());
+    $this->assertSession()->responseContains($this->getUntranslatedString());
   }
 
   /**
@@ -135,7 +135,7 @@ public function testExportTranslationTemplateFile() {
     $this->drupalGet('admin/config/regional/translate/export');
     $this->submitForm([], 'Export');
     // Ensure we have a translation file.
-    $this->assertRaw('# LANGUAGE translation of PROJECT');
+    $this->assertSession()->pageTextContains('# LANGUAGE translation of PROJECT');
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
index 6f1110fa77936feed423d4aaf656170c16ea6338..2b1cfd8d726188d64765f700e72689ddd57031de 100644
--- a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
@@ -166,8 +166,8 @@ public function testLocaleTranslationJsDependencies() {
     $js_filename = $prefix . '_' . $js_translation_files[$prefix] . '.js';
 
     $content = $this->getSession()->getPage()->getContent();
-    $this->assertRaw('core/misc/drupal.js');
-    $this->assertRaw($js_filename);
+    $this->assertSession()->responseContains('core/misc/drupal.js');
+    $this->assertSession()->responseContains($js_filename);
     // Assert translations JS is included before drupal.js.
     $this->assertLessThan(strpos($content, 'core/misc/drupal.js'), strpos($content, $js_filename));
   }
diff --git a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
index 160fe866b604eff809adbc4d2e1182f64e185780..d77e626ab3dd7703a65ee0c83d889c69488346cc 100644
--- a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
+++ b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
@@ -248,21 +248,21 @@ public function testPluralEditExport() {
     $this->drupalGet('admin/config/regional/translate/export');
     $this->submitForm(['langcode' => 'fr'], 'Export');
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal');
+    $this->assertSession()->pageTextContains('# French translation of Drupal');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw("msgid \"Monday\"\nmsgstr \"lundi\"");
+    $this->assertSession()->responseContains("msgid \"Monday\"\nmsgstr \"lundi\"");
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"");
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"");
 
     // Get the Croatian translations.
     $this->drupalGet('admin/config/regional/translate/export');
     $this->submitForm(['langcode' => 'hr'], 'Export');
     // Ensure we have a translation file.
-    $this->assertRaw('# Croatian translation of Drupal');
+    $this->assertSession()->pageTextContains('# Croatian translation of Drupal');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"");
+    $this->assertSession()->responseContains("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"");
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata\"\nmsgstr[2] \"@count sati\"");
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata\"\nmsgstr[2] \"@count sati\"");
 
     // Check if the source appears on the translation page.
     $this->drupalGet('admin/config/regional/translate');
@@ -365,15 +365,15 @@ public function testPluralEditExport() {
     $this->drupalGet('admin/config/regional/translate/export');
     $this->submitForm(['langcode' => 'fr'], 'Export');
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"");
-    $this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"");
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"");
+    $this->assertSession()->responseContains("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"");
 
     // Get the Croatian translations.
     $this->drupalGet('admin/config/regional/translate/export');
     $this->submitForm(['langcode' => 'hr'], 'Export');
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"");
-    $this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"");
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"");
+    $this->assertSession()->responseContains("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"");
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
index c7c7b94909bf5bd8f778fc61ef85f03f97c156f4..d7e0ed530da2e8de01895edbc8ef8db5098b0070 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
@@ -93,7 +93,7 @@ public function testTranslatedUpdate() {
     $this->drupalGet($update_url . '/selection', ['external' => TRUE]);
     $this->updateRequirementsProblem();
     $this->drupalGet($update_url . '/selection', ['external' => TRUE]);
-    $this->assertRaw('messages--status');
+    $this->assertSession()->responseContains('messages--status');
     $this->assertSession()->linkByHrefNotExists('fr/update.php/run', 'No link to run updates.');
   }
 
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
index 1c88b11302f69eab01281ecc0cb4476e366445ac..cdedb12cd35b163dae131f77411c16178bdc49fc 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
@@ -79,7 +79,7 @@ public function testStringTranslation() {
     t($name, [], ['langcode' => $langcode])->render();
     // Reset locale cache.
     $this->container->get('string_translation')->reset();
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
     // Ensure that test language was added.
     $this->assertSession()->pageTextContains($name);
     $this->drupalLogout();
@@ -132,7 +132,7 @@ public function testStringTranslation() {
     ];
     $this->drupalGet('admin/config/regional/translate');
     $this->submitForm($search, 'Filter');
-    $this->assertRaw($translation);
+    $this->assertSession()->pageTextContains($translation);
 
     $search = [
       'string' => $name,
@@ -155,7 +155,7 @@ public function testStringTranslation() {
     ];
     $this->drupalGet('admin/config/regional/translate');
     $this->submitForm($search, 'Filter');
-    $this->assertRaw($translation_to_en);
+    $this->assertSession()->pageTextContains($translation_to_en);
 
     $this->assertNotEquals($translation, $name);
     $this->assertEquals($translation, t($name, [], ['langcode' => $langcode]), 't() works for non-English.');
@@ -232,7 +232,7 @@ public function testStringTranslation() {
     ];
     $this->drupalGet('admin/config/regional/translate');
     $this->submitForm($edit, 'Save translations');
-    $this->assertRaw($name);
+    $this->assertSession()->responseContains($name);
     $this->drupalLogin($translate_user);
     $search = [
       'string' => $name,
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
index 2ebba84e2ddb5b93b632cd0a41ee3448fbcf8cb4..bf19edd0961eb8cb5fe1244d24923849a18c5df8 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
@@ -102,7 +102,7 @@ public function testInterface() {
       '@version' => '1.3-dev',
       '@info' => t('File not found at %local_path', ['%local_path' => 'core/modules/locale/tests/test.de.po']),
     ]);
-    $this->assertRaw($release_details->__toString());
+    $this->assertSession()->responseContains($release_details->__toString());
 
     // Override Drupal core translation status as 'no translations found'.
     $status = locale_translation_get_status();
diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
index a92a29712d6d98de4132c76163f83f42155b826f..a833b5be3d73a8abb8f2d07f8b80ee008467f24c 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
@@ -130,7 +130,7 @@ public function testUpdateImportSourceRemote() {
     $this->drupalGet('admin/reports/translations/check');
 
     // Check the status on the Available translation status page.
-    $this->assertRaw('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>');
+    $this->assertSession()->responseContains('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>');
     $this->assertSession()->pageTextContains('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test');
     /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
     $date_formatter = $this->container->get('date.formatter');
diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
index c40a11863bd65f54f915e2528e284a663ff3ebdc..b6a8fff68b2f9b768d70842af9532fa9f01d1ee6 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
@@ -201,7 +201,7 @@ public function testMediaOEmbedVideoSource() {
     // 'view media' permission.
     $this->drupalGet('media/oembed', ['query' => $query]);
     $assert_session->pageTextContains('By the power of Grayskull, Vimeo works!');
-    $this->assertRaw('core/themes/stable/templates/content/media-oembed-iframe.html.twig');
+    $this->assertSession()->responseContains('core/themes/stable/templates/content/media-oembed-iframe.html.twig');
     $this->assertSession()->responseNotContains('core/modules/media/templates/media-oembed-iframe.html.twig');
 
     // Test themes not inheriting from stable.
@@ -210,7 +210,7 @@ public function testMediaOEmbedVideoSource() {
     $this->drupalGet('media/oembed', ['query' => $query]);
     $assert_session->pageTextContains('By the power of Grayskull, Vimeo works!');
     $this->assertSession()->responseNotContains('core/themes/stable/templates/content/media-oembed-iframe.html.twig');
-    $this->assertRaw('core/modules/media/templates/media-oembed-iframe.html.twig');
+    $this->assertSession()->responseContains('core/modules/media/templates/media-oembed-iframe.html.twig');
 
     // Remove the 'view media' permission to test that this restricts access.
     $role = Role::load(AccountInterface::ANONYMOUS_ROLE);
diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php
index fd88781a4beaf0e34744236478b02b8edcf46e56..b57bc58d55c71a320ab70c17da4084fa5fa12013 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php
@@ -86,7 +86,7 @@ public function testMenuLinkContentForm() {
     $option = $this->assertSession()->optionExists('edit-menu-parent', 'admin:');
     $this->assertTrue($option->isSelected());
     // Test that the field description is present.
-    $this->assertRaw('The location this menu link points to.');
+    $this->assertSession()->pageTextContains('The location this menu link points to.');
 
     $this->submitForm([
       'title[0][value]' => t('Front page'),
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 0d5dbdac8a53d790e8e4229b44e6acb8d3f04823..a7ddeed92dd1bfb234d2174ea2656906b944b26d 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
@@ -100,10 +100,10 @@ public function testTranslationLinkTheme() {
     $this->submitForm($edit, 'Save configuration');
     // Check that edit uses the admin theme.
     $this->drupalGet('admin/structure/menu/item/' . $entityId . '/edit');
-    $this->assertRaw('core/themes/seven/css/base/elements.css');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css');
     // Check that translation uses admin theme as well.
     $this->drupalGet('admin/structure/menu/item/' . $entityId . '/edit/translations');
-    $this->assertRaw('core/themes/seven/css/base/elements.css');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css');
   }
 
   /**
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
index fd9d1328c5ea86b873f53b83d3b97fd8ca7dd012..2ded666bff89cd3ab9e338c53e098107f2c2ce64 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
@@ -187,14 +187,14 @@ public function addCustomMenuCRUD() {
 
     // Assert the new menu.
     $this->drupalGet('admin/structure/menu/manage/' . $menu_name);
-    $this->assertRaw($label);
+    $this->assertSession()->pageTextContains($label);
 
     // Edit the menu.
     $new_label = $this->randomMachineName(16);
     $menu->set('label', $new_label);
     $menu->save();
     $this->drupalGet('admin/structure/menu/manage/' . $menu_name);
-    $this->assertRaw($new_label);
+    $this->assertSession()->pageTextContains($new_label);
   }
 
   /**
diff --git a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
index dc617655018bed71ed134fc18977a9ed36d1dc6a..08c567448c9fca452dbe6445494ca26a67ae8071 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
@@ -118,7 +118,7 @@ public function testNodeAccessAdministerField() {
 
     // Confirm that the new default value appears when creating a new node.
     $this->drupalGet('node/add/page');
-    $this->assertRaw($default);
+    $this->assertSession()->responseContains($default);
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
index be68b22395c09506df7ff03dd56e11f65e0ca20e..c47c35dda157fa5cb9f869e97f82d7d408051f9a 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
@@ -70,7 +70,7 @@ public function testCommentPager() {
     $this->drupalGet('node/' . $node->id());
     $this->assertSession()->pageTextContains($node->label());
     $this->assertSession()->pageTextContains('Comments');
-    $this->assertRaw('page=1');
+    $this->assertSession()->responseContains('page=1');
     $this->assertSession()->responseNotContains('page=2');
   }
 
@@ -102,7 +102,7 @@ public function testForumPager() {
     // page there should be two pages for 30 nodes, no more.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('forum/' . $tid);
-    $this->assertRaw('page=1');
+    $this->assertSession()->responseContains('page=1');
     $this->assertSession()->responseNotContains('page=2');
   }
 
diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
index 1abadcb6fa28ec5ad03bfff859d339a969b08795..73311dbe78cf5969cea7cffcc4539e6eec7489b3 100644
--- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php
+++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
@@ -86,7 +86,7 @@ public function testNodeEdit() {
 
     // Check that the title and body fields are displayed with the correct values.
     // @todo Ideally assertLink would support HTML, but it doesn't.
-    $this->assertRaw('Edit<span class="visually-hidden">(active tab)</span>');
+    $this->assertSession()->responseContains('Edit<span class="visually-hidden">(active tab)</span>');
     $this->assertSession()->fieldValueEquals($title_key, $edit[$title_key]);
     $this->assertSession()->fieldValueEquals($body_key, $edit[$body_key]);
 
@@ -141,7 +141,7 @@ public function testNodeEdit() {
     $open_details_elements = count($this->cssSelect('details[open="open"]'));
     $this->submitForm($edit, 'Save');
     // The node author details must be open.
-    $this->assertRaw('<details class="node-form-author js-form-wrapper form-wrapper" data-drupal-selector="edit-author" id="edit-author" open="open">');
+    $this->assertSession()->responseContains('<details class="node-form-author js-form-wrapper form-wrapper" data-drupal-selector="edit-author" id="edit-author" open="open">');
     // Only one extra details element should now be open.
     $open_details_elements++;
     $this->assertCount($open_details_elements, $this->cssSelect('details[open="open"]'), 'Exactly one extra open &lt;details&gt; element found.');
diff --git a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
index fd917dc6b9a369a17c63b219e4281a4e013c0c6a..4939108c87c07603b76dfd1824b211f08e174cca 100644
--- a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
+++ b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
@@ -109,12 +109,12 @@ public function testMultilingualNodeForm() {
     $this->drupalGet("it/node/{$node->id()}");
     // Verify that body is correctly displayed using Italian as requested
     // language.
-    $this->assertRaw($body_value);
+    $this->assertSession()->pageTextContains($body_value);
 
     $this->drupalGet("node/{$node->id()}");
     // Verify that body is correctly displayed using English as requested
     // language.
-    $this->assertRaw($body_value);
+    $this->assertSession()->pageTextContains($body_value);
   }
 
   /**
diff --git a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
index ad4aa767d5d6d49d5006ed4d02f2431e2a026af6..1fd49d3eb67b1915d6390f32a35f6953ffb63e34 100644
--- a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
@@ -62,8 +62,8 @@ public function testNodeRSSContent() {
     // Check that extra RSS elements and namespaces are added to RSS feed.
     $test_element = '<testElement>' . t('Value of testElement RSS element for node @nid.', ['@nid' => $node->id()]) . '</testElement>';
     $test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"';
-    $this->assertRaw($test_element);
-    $this->assertRaw($test_ns);
+    $this->assertSession()->responseContains($test_element);
+    $this->assertSession()->responseContains($test_ns);
 
     // Check that content added in 'rss' view mode doesn't appear when
     // viewing node.
@@ -114,9 +114,9 @@ public function testUrlHandling() {
     // Verify that root-relative URL is transformed to absolute.
     $this->assertSession()->responseContains($file_url_generator->generateAbsoluteString('public://root-relative'));
     // Verify that protocol-relative URL is left untouched.
-    $this->assertRaw($protocol_relative_url);
+    $this->assertSession()->responseContains($protocol_relative_url);
     // Verify that absolute URL is left untouched.
-    $this->assertRaw($absolute_url);
+    $this->assertSession()->responseContains($absolute_url);
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
index 5a79087328cba5414bae4ec54bfb469c75c8ccde..151bff2e03369dc0a7b844d8d04757bbae9ef98f 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
@@ -208,7 +208,7 @@ public function testRevisions() {
     $this->drupalGet('node/' . $node->id() . '/revisions');
 
     // Check that the pager exists.
-    $this->assertRaw('page=1');
+    $this->assertSession()->responseContains('page=1');
 
     // Check that the last revision is displayed on the first page.
     $this->assertSession()->pageTextContains(end($logs));
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
index fb5961beda807fe72fbba4d89bdb48c1f92fbe75..833cef792df1c07ac291367a780725b6c3dcf17c 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
@@ -122,11 +122,11 @@ public function testNodeRevisionDoubleEscapeFix() {
     // Assert the old revision message.
     $date = $this->container->get('date.formatter')->format($nodes[0]->revision_timestamp->value, 'short');
     $url = new Url('entity.node.revision', ['node' => $nodes[0]->id(), 'node_revision' => $nodes[0]->getRevisionId()]);
-    $this->assertRaw(Link::fromTextAndUrl($date, $url)->toString() . ' by ' . $editor);
+    $this->assertSession()->responseContains(Link::fromTextAndUrl($date, $url)->toString() . ' by ' . $editor);
 
     // Assert the current revision message.
     $date = $this->container->get('date.formatter')->format($nodes[1]->revision_timestamp->value, 'short');
-    $this->assertRaw($nodes[1]->toLink($date)->toString() . ' by ' . $editor . '<p class="revision-log">' . $revision_log . '</p>');
+    $this->assertSession()->responseContains($nodes[1]->toLink($date)->toString() . ' by ' . $editor . '<p class="revision-log">' . $revision_log . '</p>');
   }
 
   /**
diff --git a/core/modules/node/tests/src/Functional/NodeTitleTest.php b/core/modules/node/tests/src/Functional/NodeTitleTest.php
index ea3878aec96e1fd356a1e3b200a858d7845028cb..6ac592f63361a00d44c1333c07759aad84e0b59c 100644
--- a/core/modules/node/tests/src/Functional/NodeTitleTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTitleTest.php
@@ -103,11 +103,11 @@ public function testNodeTitle() {
     // the page.
     $edge_case_title_escaped = Html::escape($edge_case_title);
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw('<title>' . $edge_case_title_escaped . ' | Drupal</title>');
+    $this->assertSession()->responseContains('<title>' . $edge_case_title_escaped . ' | Drupal</title>');
 
     // Test that the title appears as <title> when reloading the node page.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw('<title>' . $edge_case_title_escaped . ' | Drupal</title>');
+    $this->assertSession()->responseContains('<title>' . $edge_case_title_escaped . ' | Drupal</title>');
 
   }
 
diff --git a/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
index 10cbb14c5ef02c59c720cb4d9116613b75e56388..dcbac6a1ef0a7cb64140b3b807e528dc29dfdc73 100644
--- a/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
@@ -43,7 +43,7 @@ public function testNodeTitleXSS() {
 
     $this->drupalGet('node/' . $node->id());
     // Titles should be escaped.
-    $this->assertRaw('<title>' . Html::escape($title) . ' | Drupal</title>');
+    $this->assertSession()->responseContains('<title>' . Html::escape($title) . ' | Drupal</title>');
     $this->assertSession()->responseNotContains($xss);
 
     $this->drupalGet('node/' . $node->id() . '/edit');
diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
index e909f5db69ecce23698c2d725779c269dbdccbf9..624c70906c83139049af2c76197aaa9aefbd9866 100644
--- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -261,7 +261,7 @@ public function testTranslationLinkTheme() {
     $this->submitForm($edit, 'Save configuration');
     $this->drupalGet('node/' . $article->id() . '/translations');
     // Verify that translation uses the admin theme if edit is admin.
-    $this->assertRaw('core/themes/seven/css/base/elements.css');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css');
 
     // Turn off admin theme for editing, assert inheritance to translations.
     $edit['use_admin_theme'] = FALSE;
diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php
index a9f22eed41e77432fa1514fd7430816f8d551acb..4eca2c42b381b8ae096df23e67f5069a03b91d80 100644
--- a/core/modules/node/tests/src/Functional/PagePreviewTest.php
+++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php
@@ -230,7 +230,7 @@ public function testPagePreview() {
     $view_mode_edit = ['view_mode' => 'teaser'];
     $this->drupalGet('node/preview/' . $uuid . '/full');
     $this->submitForm($view_mode_edit, 'Switch');
-    $this->assertRaw('view-mode-teaser');
+    $this->assertSession()->responseContains('view-mode-teaser');
     $this->assertSession()->pageTextNotContains($edit[$body_key]);
 
     // Check that the title, body and term fields are displayed with the
@@ -280,8 +280,8 @@ public function testPagePreview() {
     $edit[$term_key] = $this->term->getName() . ', ' . $newterm1 . ', ' . $newterm2;
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Preview');
-    $this->assertRaw('>' . $newterm1 . '<');
-    $this->assertRaw('>' . $newterm2 . '<');
+    $this->assertSession()->responseContains('>' . $newterm1 . '<');
+    $this->assertSession()->responseContains('>' . $newterm2 . '<');
     // The first term should be displayed as link, the others not.
     $this->assertSession()->linkExists($this->term->getName());
     $this->assertSession()->linkNotExists($newterm1);
@@ -297,9 +297,9 @@ public function testPagePreview() {
     $edit[$term_key] = $newterm1 . ', ' . $newterm3 . ', ' . $newterm2;
     $this->drupalGet('node/' . $node->id() . '/edit');
     $this->submitForm($edit, 'Preview');
-    $this->assertRaw('>' . $newterm1 . '<');
-    $this->assertRaw('>' . $newterm2 . '<');
-    $this->assertRaw('>' . $newterm3 . '<');
+    $this->assertSession()->responseContains('>' . $newterm1 . '<');
+    $this->assertSession()->responseContains('>' . $newterm2 . '<');
+    $this->assertSession()->responseContains('>' . $newterm3 . '<');
     $this->assertSession()->pageTextNotContains($this->term->getName());
     $this->assertSession()->linkExists($newterm1);
     $this->assertSession()->linkExists($newterm2);
@@ -330,7 +330,7 @@ public function testPagePreview() {
     $this->drupalGet('node/add/page');
     $this->submitForm([$title_key => 'Preview'], 'Preview');
     $this->clickLink('Back to content editing');
-    $this->assertRaw('edit-submit');
+    $this->assertSession()->responseContains('edit-submit');
 
     // Check that destination is remembered when clicking on preview. When going
     // back to the edit form and clicking save, we should go back to the
@@ -383,10 +383,10 @@ public function testPagePreview() {
       'title[0][value]' => $title,
       'field_test_multi[0][value]' => $example_text_1,
     ];
-    $this->assertRaw('Storage is not set');
+    $this->assertSession()->pageTextContains('Storage is not set');
     $this->submitForm($edit, 'Preview');
     $this->clickLink('Back to content editing');
-    $this->assertRaw('Storage is set');
+    $this->assertSession()->pageTextContains('Storage is set');
     $this->assertSession()->fieldExists('field_test_multi[0][value]');
     $this->submitForm([], 'Save');
     $this->assertSession()->pageTextContains('Basic page ' . $title . ' has been created.');
diff --git a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php
index aff2832b5fe50e16137360043f6377b658072a51..d3abb517febfe54e172ae86fbf119973168f8316 100644
--- a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php
+++ b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\node\Functional\Views;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
 
@@ -94,11 +93,7 @@ public function testNodeEditAccess() {
     ];
     $this->drupalGet('test-node-bulk-form');
     $this->submitForm($edit, 'Apply to selected items');
-    $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [
-      '%action' => 'Unpublish content',
-      '@entity_type_label' => 'Content',
-      '%entity_label' => $node->label(),
-    ]));
+    $this->assertSession()->pageTextContains("No access to execute Unpublish content on the Content {$node->label()}.");
 
     // Re-load the node and check the status.
     $node = Node::load($node->id());
@@ -139,11 +134,7 @@ public function testNodeEditAccess() {
     $this->drupalGet('test-node-bulk-form');
     $this->submitForm($edit, 'Apply to selected items');
     // Test that the action message isn't shown.
-    $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [
-      '%action' => 'Delete content',
-      '@entity_type_label' => 'Content',
-      '%entity_label' => $node->label(),
-    ]));
+    $this->assertSession()->pageTextContains("No access to execute Delete content on the Content {$node->label()}.");
     $this->assertNotEmpty($this->cssSelect('#views-form-test-node-bulk-form-page-1'));
   }
 
diff --git a/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php b/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php
index 2da46e73114aa1424eb4ae3a9ac97c9a5963cc95..4f69fd374c6d7505c6f4403823eff9a78086c66b 100644
--- a/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php
+++ b/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php
@@ -53,16 +53,16 @@ public function testViewsTokenReplacement() {
     $this->drupalGet('test_node_tokens');
 
     // Body: {{ body }}<br />
-    $this->assertRaw("Body: <p>$body</p>");
+    $this->assertSession()->responseContains("Body: <p>$body</p>");
 
     // Raw value: {{ body__value }}<br />
-    $this->assertRaw("Raw value: $body");
+    $this->assertSession()->responseContains("Raw value: $body");
 
     // Raw summary: {{ body__summary }}<br />
-    $this->assertRaw("Raw summary: $summary");
+    $this->assertSession()->responseContains("Raw summary: $summary");
 
     // Raw format: {{ body__format }}<br />
-    $this->assertRaw("Raw format: plain_text");
+    $this->assertSession()->responseContains("Raw format: plain_text");
   }
 
 }
diff --git a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
index 8aa4df106c5ef5f5279cbbca520a417ff1c88103..486c0b21c96a90e86aaddb32af7ccf3aa3c31822 100644
--- a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
+++ b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
@@ -148,8 +148,8 @@ public function testRadioButtons() {
     $this->assertSession()->checkboxNotChecked('edit-card-1-0');
     $this->assertSession()->checkboxNotChecked('edit-card-1-1');
     $this->assertSession()->checkboxNotChecked('edit-card-1-2');
-    $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>');
-    $this->assertRaw('Some HTML encoded markup with &lt; &amp; &gt;');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped <strong>markup</strong>');
+    $this->assertSession()->responseContains('Some HTML encoded markup with &lt; &amp; &gt;');
 
     // Select first option.
     $edit = ['card_1' => 0];
@@ -206,7 +206,7 @@ public function testCheckBoxes() {
     $this->assertSession()->checkboxNotChecked('edit-card-2-0');
     $this->assertSession()->checkboxNotChecked('edit-card-2-1');
     $this->assertSession()->checkboxNotChecked('edit-card-2-2');
-    $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped <strong>markup</strong>');
 
     // Submit form: select first and third options.
     $edit = [
@@ -303,7 +303,7 @@ public function testSelectListSingle() {
     $this->assertFalse($this->assertSession()->optionExists('card_1', 0)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
-    $this->assertRaw('Some dangerous &amp; unescaped markup');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup');
 
     // Submit form: select invalid 'none' option.
     $edit = ['card_1' => '_none'];
@@ -349,9 +349,9 @@ public function testSelectListSingle() {
     $this->assertFalse($this->assertSession()->optionExists('card_1', 0)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
-    $this->assertRaw('Some dangerous &amp; unescaped markup');
-    $this->assertRaw('More &lt;script&gt;dangerous&lt;/script&gt; markup');
-    $this->assertRaw('Group 1');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup');
+    $this->assertSession()->responseContains('More &lt;script&gt;dangerous&lt;/script&gt; markup');
+    $this->assertSession()->responseContains('Group 1');
 
     // Submit form: select first option.
     $edit = ['card_1' => 0];
@@ -402,7 +402,7 @@ public function testSelectListMultiple() {
     $this->assertFalse($this->assertSession()->optionExists('card_2', 0)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
-    $this->assertRaw('Some dangerous &amp; unescaped markup');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup');
 
     // Submit form: select first and third options.
     $edit = ['card_2[]' => [0 => 0, 2 => 2]];
@@ -474,9 +474,9 @@ public function testSelectListMultiple() {
     $this->assertFalse($this->assertSession()->optionExists('card_2', 0)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
     $this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
-    $this->assertRaw('Some dangerous &amp; unescaped markup');
-    $this->assertRaw('More &lt;script&gt;dangerous&lt;/script&gt; markup');
-    $this->assertRaw('Group 1');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup');
+    $this->assertSession()->responseContains('More &lt;script&gt;dangerous&lt;/script&gt; markup');
+    $this->assertSession()->responseContains('Group 1');
 
     // Submit form: select first option.
     $edit = ['card_2[]' => [0 => 0]];
diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
index ab661775eb177eec3f3cf7db1cda8e60049ca18a..731ba040458916a004e20abfc7b12b0b5b2c387c 100644
--- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
+++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
@@ -137,7 +137,7 @@ public function testQueryParameterFormatRequests() {
     // Verify that HTML page was cached.
     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     // Verify that the correct HTML response was returned.
-    $this->assertRaw('<p>oh hai this is html.</p>');
+    $this->assertSession()->responseContains('<p>oh hai this is html.</p>');
 
     $this->drupalGet($accept_header_cache_url_with_json);
     // Verify that JSON response was not yet cached.
@@ -146,7 +146,7 @@ public function testQueryParameterFormatRequests() {
     // Verify that JSON response was cached.
     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
     // Verify that the correct JSON response was returned.
-    $this->assertRaw('{"content":"oh hai this is json"}');
+    $this->assertSession()->responseContains('{"content":"oh hai this is json"}');
 
     // Enable REST support for nodes and hal+json.
     \Drupal::service('module_installer')->install(['node', 'rest', 'hal', 'basic_auth']);
diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
index 64131a273aed74297b9e0085033e449ea0905199..86e95b75e67da2c138ac6c340eabe4173302a295 100644
--- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
@@ -195,8 +195,8 @@ public function testWithPendingRevision() {
     $this->assertSession()->responseNotContains('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
 
     $this->drupalGet('node/' . $this->testNode->id());
-    $this->assertRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
-    $this->assertRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
+    $this->assertSession()->responseContains('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
+    $this->assertSession()->responseContains('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
 
     // Wait for the page to completely load before making any changes to the
     // node. This allows Quick Edit to fetch the metadata without causing
@@ -335,7 +335,7 @@ public function testContentBlock() {
     // Check that the data- attribute is present.
     $this->drupalLogin($this->editorUser);
     $this->drupalGet('');
-    $this->assertRaw('data-quickedit-entity-id="block_content/1"');
+    $this->assertSession()->responseContains('data-quickedit-entity-id="block_content/1"');
   }
 
   /**
diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
index e6656c19b6c88d477ed3c3d67f6502aafc9c25a5..83e571c11ce3f4bfad27e41537cfa50dec890a81 100644
--- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
@@ -213,7 +213,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       '#alt' => $alt,
     ];
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     // Test field not being configured. This should not cause a fatal error.
     $display_options = [
@@ -299,32 +299,32 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
     // Output should contain all image styles and all breakpoints.
     $this->drupalGet('node/' . $nid);
     if (!$empty_styles) {
-      $this->assertRaw('/styles/medium/');
+      $this->assertSession()->responseContains('/styles/medium/');
       // Assert the empty image is present.
-      $this->assertRaw('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
+      $this->assertSession()->responseContains('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
       $thumbnail_style = ImageStyle::load('thumbnail');
       // Assert the output of the 'srcset' attribute (small multipliers first).
       $this->assertSession()->responseContains('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== 1x, ' . $this->fileUrlGenerator->transformRelative($thumbnail_style->buildUrl($image_uri)) . ' 1.5x');
-      $this->assertRaw('/styles/medium/');
+      $this->assertSession()->responseContains('/styles/medium/');
       // Assert the output of the original image.
       $this->assertSession()->responseContains($this->fileUrlGenerator->generateString($image_uri) . ' 3x');
       // Assert the output of the breakpoints.
-      $this->assertRaw('media="(min-width: 0px)"');
-      $this->assertRaw('media="(min-width: 560px)"');
+      $this->assertSession()->responseContains('media="(min-width: 0px)"');
+      $this->assertSession()->responseContains('media="(min-width: 560px)"');
       // Assert the output of the 'sizes' attribute.
-      $this->assertRaw('sizes="(min-width: 700px) 700px, 100vw"');
+      $this->assertSession()->responseContains('sizes="(min-width: 700px) 700px, 100vw"');
       $this->assertSession()->responseMatches('/media="\(min-width: 560px\)".+?sizes="\(min-width: 700px\) 700px, 100vw"/');
       // Assert the output of the 'srcset' attribute (small images first).
       $medium_style = ImageStyle::load('medium');
       $this->assertSession()->responseContains($this->fileUrlGenerator->transformRelative($medium_style->buildUrl($image_uri)) . ' 220w, ' . $this->fileUrlGenerator->transformRelative($large_style->buildUrl($image_uri)) . ' 360w');
-      $this->assertRaw('media="(min-width: 851px)"');
+      $this->assertSession()->responseContains('media="(min-width: 851px)"');
     }
-    $this->assertRaw('/styles/large/');
+    $this->assertSession()->responseContains('/styles/large/');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:responsive_image.styles.style_one');
     if (!$empty_styles) {
       $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.medium');
       $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.thumbnail');
-      $this->assertRaw('type="image/png"');
+      $this->assertSession()->responseContains('type="image/png"');
     }
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:image.style.large');
 
@@ -339,7 +339,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
     // responsive-image.html.twig doesn't have one after the fallback image, so
     // we remove it here.
     $default_output = trim($renderer->renderRoot($fallback_image));
-    $this->assertRaw($default_output);
+    $this->assertSession()->responseContains($default_output);
 
     if ($scheme == 'private') {
       // Log out and ensure the file cannot be accessed.
diff --git a/core/modules/search/tests/src/Functional/SearchAdminThemeTest.php b/core/modules/search/tests/src/Functional/SearchAdminThemeTest.php
index 2cd49c8a91091fe9087412030d12b0c682b04d9e..10f35c8ccd8661cf9b8bc1d46f12fc88ca31bfa7 100644
--- a/core/modules/search/tests/src/Functional/SearchAdminThemeTest.php
+++ b/core/modules/search/tests/src/Functional/SearchAdminThemeTest.php
@@ -96,7 +96,7 @@ public function testSearchUsingAdminTheme() {
    */
   protected function assertAdminTheme($is_admin) {
     if ($is_admin) {
-      $this->assertRaw('core/themes/' . $this->adminTheme);
+      $this->assertSession()->responseContains('core/themes/' . $this->adminTheme);
     }
     else {
       $this->assertSession()->responseNotContains('core/themes/' . $this->adminTheme);
diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php
index 974d494ee21c124b682bf410e160142a29e713ae..2c349779a59de31dd91a8a77d9e9235ee268909d 100644
--- a/core/modules/search/tests/src/Functional/SearchCommentTest.php
+++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php
@@ -189,7 +189,7 @@ public function testSearchResultsComment() {
     $this->submitForm($edit, 'Search');
 
     // Verify the evil comment subject is escaped in search results.
-    $this->assertRaw('&lt;script&gt;alert(&#039;<strong>subjectkeyword</strong>&#039;);');
+    $this->assertSession()->responseContains('&lt;script&gt;alert(&#039;<strong>subjectkeyword</strong>&#039;);');
     $this->assertSession()->responseNotContains('<script>');
 
     // Search for the keyword near the evil script tag in the comment body.
@@ -201,7 +201,7 @@ public function testSearchResultsComment() {
 
     // Verify that nearby script tag in the evil comment body is stripped from
     // search results.
-    $this->assertRaw('<strong>nearbykeyword</strong>');
+    $this->assertSession()->responseContains('<strong>nearbykeyword</strong>');
     $this->assertSession()->responseNotContains('<script>');
 
     // Search for contents inside the evil script tag in the comment body.
diff --git a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
index dbc42e2d3e3a53c9a4ce9796701f02df52c46ba6..ac6f7452297293a06ec6d7b424002c32ddb216e0 100644
--- a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
@@ -70,7 +70,7 @@ public function testSearchKeywordsConditions() {
     $keys = 'moving drop ' . $this->randomMachineName();
     $this->drupalGet("search/dummy_path", ['query' => ['keys' => 'bike', 'search_conditions' => $keys]]);
     $this->assertSession()->pageTextContains("Dummy search snippet to display.");
-    $this->assertRaw(Html::escape(print_r(['keys' => 'bike', 'search_conditions' => $keys], TRUE)));
+    $this->assertSession()->responseContains(Html::escape(print_r(['keys' => 'bike', 'search_conditions' => $keys], TRUE)));
   }
 
 }
diff --git a/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php b/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
index 87157b4736dd5b4a552619caccf290a97cbc9a11..09d9db2c7eb8624c503a2a335cf86d7b527052c0 100644
--- a/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
@@ -63,31 +63,31 @@ public function testPhraseSearchPunctuation() {
     $edit = ['keys' => 'meklet'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>meklēt</strong>');
+    $this->assertSession()->responseContains('<strong>meklēt</strong>');
 
     $edit = ['keys' => 'meklēt'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>meklēt</strong>');
+    $this->assertSession()->responseContains('<strong>meklēt</strong>');
 
     $edit = ['keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>cómmīŦŧęđ</strong>');
-    $this->assertRaw('<strong>BɆĬŇĜ</strong>');
-    $this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
+    $this->assertSession()->responseContains('<strong>cómmīŦŧęđ</strong>');
+    $this->assertSession()->responseContains('<strong>BɆĬŇĜ</strong>');
+    $this->assertSession()->responseContains('<strong>påŔťıçȉpǎǹţș</strong>');
 
     $edit = ['keys' => 'committed being participants'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>cómmīŦŧęđ</strong>');
-    $this->assertRaw('<strong>BɆĬŇĜ</strong>');
-    $this->assertRaw('<strong>påŔťıçȉpǎǹţș</strong>');
+    $this->assertSession()->responseContains('<strong>cómmīŦŧęđ</strong>');
+    $this->assertSession()->responseContains('<strong>BɆĬŇĜ</strong>');
+    $this->assertSession()->responseContains('<strong>påŔťıçȉpǎǹţș</strong>');
 
     $edit = ['keys' => 'Enricþment'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>Enricþment</strong>');
+    $this->assertSession()->responseContains('<strong>Enricþment</strong>');
 
     $edit = ['keys' => 'Enritchment'];
     $this->drupalGet('search/node');
@@ -97,7 +97,7 @@ public function testPhraseSearchPunctuation() {
     $edit = ['keys' => 'æll'];
     $this->drupalGet('search/node');
     $this->submitForm($edit, 'Search');
-    $this->assertRaw('<strong>æll</strong>');
+    $this->assertSession()->responseContains('<strong>æll</strong>');
 
     $edit = ['keys' => 'all'];
     $this->drupalGet('search/node');
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
index 463340eedadfb786581222c2e973c67445b41c86..a3029053f4e2e9d1ec1160aca8aaf132fb9c7a7d 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
@@ -70,7 +70,7 @@ public function testShortcutLinkAdd() {
     // Test the add shortcut form UI. Test that the base field description is
     // there.
     $this->drupalGet('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link');
-    $this->assertRaw('The location this shortcut points to.');
+    $this->assertSession()->pageTextContains('The location this shortcut points to.');
 
     // Check that each new shortcut links where it should.
     foreach ($test_cases as $test_path) {
@@ -219,14 +219,11 @@ public function testShortcutQuickLink() {
     ])->save();
     // Test page with HTML tags in title.
     $this->drupalGet('admin/structure/block/block-content/manage/basic');
-    $page_title = new FormattableMarkup('Edit %label custom block type', ['%label' => 'Basic block']);
-    $this->assertRaw($page_title);
+    $page_title = "Edit Basic block custom block type";
+    $this->assertSession()->pageTextContains($page_title);
     // Add shortcut to this page.
     $this->clickLink('Add to Default shortcuts');
-    $this->assertRaw(new FormattableMarkup('Added a shortcut for %title.', [
-      '%title' => trim(strip_tags($page_title)),
-    ]));
-
+    $this->assertSession()->pageTextContains("Added a shortcut for {$page_title}.");
   }
 
   /**
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
index 73f95f671aec908d62f3aab71a2539983bad86a8..af98752abaee3a048624a57107e13c0c352604fa 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
@@ -56,7 +56,7 @@ public function testAttached() {
     $node->save();
     $this->drupalGet('node/' . $node->id());
 
-    $this->assertRaw('core/modules/statistics/statistics.js');
+    $this->assertSession()->responseContains('core/modules/statistics/statistics.js');
   }
 
 }
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php b/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php
index 7138d73bd7b548e67442030fda5cc0ef305e5566..352943df22a6d78a87cb98c8a3f9ff2683e905e6 100644
--- a/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php
+++ b/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php
@@ -63,7 +63,7 @@ public function testPopularContentBlock() {
     $this->assertCacheContexts($contexts);
 
     // Check if the node link is displayed.
-    $this->assertRaw(Link::fromTextAndUrl($node->label(), $node->toUrl('canonical'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl($node->label(), $node->toUrl('canonical'))->toString());
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php
index 5bc95543b51a09e34b08d14a9f4ed86d0551a453..1d1854dc094938334d01b42b0761657d3259f07a 100644
--- a/core/modules/system/tests/src/Functional/Batch/PageTest.php
+++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php
@@ -78,13 +78,13 @@ public function testBatchProgressMessages() {
     $this->drupalGet('batch-test/test-title');
     // Check that the initial progress message appears correctly and is not
     // double escaped.
-    $this->assertRaw('<div class="progress__description">Initializing.<br />&nbsp;</div>');
+    $this->assertSession()->responseContains('<div class="progress__description">Initializing.<br />&nbsp;</div>');
     $this->assertSession()->responseNotContains('&amp;nbsp;');
     // Now also go to the next step.
     $this->maximumMetaRefreshCount = 1;
     $this->drupalGet('batch-test/test-title');
     // Check that the progress message for second step appears correctly.
-    $this->assertRaw('<div class="progress__description">Completed 1 of 1.</div>');
+    $this->assertSession()->responseContains('<div class="progress__description">Completed 1 of 1.</div>');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
index ff355952f7eaecf79c504966ac248941e6a034da..72dcca53be9cfb55f5a78ff0e1d788052168ba90 100644
--- a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
+++ b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
@@ -39,9 +39,9 @@ public function testDrupalMessengerService() {
     $this->assertSession()->pageTextMatchesCount(3, '/Duplicated message/');
 
     // Ensure Markup objects are rendered as expected.
-    $this->assertRaw('Markup with <em>markup!</em>');
+    $this->assertSession()->responseContains('Markup with <em>markup!</em>');
     $this->assertSession()->pageTextMatchesCount(1, '/Markup with markup!/');
-    $this->assertRaw('Markup2 with <em>markup!</em>');
+    $this->assertSession()->responseContains('Markup2 with <em>markup!</em>');
 
     // Ensure when the same message is of different types it is not duplicated.
     $this->assertSession()->pageTextMatchesCount(1, '$Non duplicate Markup / string.$');
diff --git a/core/modules/system/tests/src/Functional/Cache/SessionExistsCacheContextTest.php b/core/modules/system/tests/src/Functional/Cache/SessionExistsCacheContextTest.php
index 0bc90014c5aea241eb5a7b197998f98875dd0a2c..e7561716cbb4926a248eddaa8ce124b44c9fd36f 100644
--- a/core/modules/system/tests/src/Functional/Cache/SessionExistsCacheContextTest.php
+++ b/core/modules/system/tests/src/Functional/Cache/SessionExistsCacheContextTest.php
@@ -34,30 +34,30 @@ public function testCacheContext() {
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertSessionCookieOnClient(FALSE);
-    $this->assertRaw('Session does not exist!');
-    $this->assertRaw('[session.exists]=0');
+    $this->assertSession()->pageTextContains('Session does not exist!');
+    $this->assertSession()->responseContains('[session.exists]=0');
 
     // 2. Session (authenticated).
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalLogin($this->rootUser);
     $this->assertSessionCookieOnClient(TRUE);
-    $this->assertRaw('Session exists!');
-    $this->assertRaw('[session.exists]=1');
+    $this->assertSession()->pageTextContains('Session exists!');
+    $this->assertSession()->responseContains('[session.exists]=1');
     $this->drupalLogout();
     $this->assertSessionCookieOnClient(FALSE);
-    $this->assertRaw('Session does not exist!');
-    $this->assertRaw('[session.exists]=0');
+    $this->assertSession()->pageTextContains('Session does not exist!');
+    $this->assertSession()->responseContains('[session.exists]=0');
 
     // 3. Session (anonymous).
     $this->assertSessionCookieOnClient(FALSE);
     $this->drupalGet(Url::fromRoute('<front>', [], ['query' => ['trigger_session' => 1]]));
     $this->assertSessionCookieOnClient(TRUE);
-    $this->assertRaw('Session does not exist!');
-    $this->assertRaw('[session.exists]=0');
+    $this->assertSession()->pageTextContains('Session does not exist!');
+    $this->assertSession()->responseContains('[session.exists]=0');
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertSessionCookieOnClient(TRUE);
-    $this->assertRaw('Session exists!');
-    $this->assertRaw('[session.exists]=1');
+    $this->assertSession()->pageTextContains('Session exists!');
+    $this->assertSession()->responseContains('[session.exists]=1');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php b/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php
index afc04b784a6d1e8ed6dd861390dec8b72f11ffb1..fa91dc95d99c97a70a135960565904f353a51217 100644
--- a/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php
+++ b/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php
@@ -34,11 +34,11 @@ public function testEarlyRendering() {
     // Render array: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'foo');
 
     // AjaxResponse: non-early & early.
@@ -46,66 +46,66 @@ public function testEarlyRendering() {
     //   https://www.drupal.org/node/956186.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.ajax_response'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.ajax_response.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
 
     // Basic Response object: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
 
     // Response object with attachments: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response-with-attachments'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response-with-attachments.early'));
     $this->assertSession()->statusCodeEquals(500);
-    $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestResponse.');
+    $this->assertSession()->pageTextContains('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestResponse.');
 
     // Cacheable Response object: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-response'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->pageTextContains('Hello world!');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-response.early'));
     $this->assertSession()->statusCodeEquals(500);
-    $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestResponse.');
+    $this->assertSession()->pageTextContains('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestResponse.');
 
     // Basic domain object: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('TestDomainObject');
+    $this->assertSession()->pageTextContains('TestDomainObject');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('TestDomainObject');
+    $this->assertSession()->pageTextContains('TestDomainObject');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
 
     // Basic domain object with attachments: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object-with-attachments'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('AttachmentsTestDomainObject');
+    $this->assertSession()->pageTextContains('AttachmentsTestDomainObject');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object-with-attachments.early'));
     $this->assertSession()->statusCodeEquals(500);
-    $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestDomainObject.');
+    $this->assertSession()->pageTextContains('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestDomainObject.');
 
     // Cacheable Response object: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-domain-object'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('CacheableTestDomainObject');
+    $this->assertSession()->pageTextContains('CacheableTestDomainObject');
     $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-domain-object.early'));
     $this->assertSession()->statusCodeEquals(500);
-    $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestDomainObject.');
+    $this->assertSession()->pageTextContains('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestDomainObject.');
 
     // The exceptions are expected. Do not interpret them as a test failure.
     // Not using File API; a potential error must trigger a PHP warning.
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
index b71cdc27205087fa311cf1b2c05ad8065a4d8f96..b4c90a3419aadb87f66b5277d47c3fbde246ceff 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
@@ -49,13 +49,13 @@ public function testPager() {
     $this->drupalGet('entity_test/list');
 
     // Item 51 should not be present.
-    $this->assertRaw('Test entity 50');
+    $this->assertSession()->pageTextContains('Test entity 50');
     $this->assertSession()->responseNotContains('Test entity 51');
 
     // Browse to the next page, test entity 51 is shown.
     $this->clickLink('Page 2');
     $this->assertSession()->responseNotContains('Test entity 50');
-    $this->assertRaw('Test entity 51');
+    $this->assertSession()->pageTextContains('Test entity 51');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
index ee865b06a0165402bbafe26e03c6c70dc8d28cb3..8ec23e044b3542745e33bcd2299e7b53fad486bd 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
@@ -55,17 +55,17 @@ public function testEntityViewController() {
 
     foreach ($this->entities as $entity) {
       $this->drupalGet('entity_test/' . $entity->id());
-      $this->assertRaw($entity->label());
-      $this->assertRaw($get_label_markup($entity->label()));
-      $this->assertRaw('full');
+      $this->assertSession()->pageTextContains($entity->label());
+      $this->assertSession()->responseContains($get_label_markup($entity->label()));
+      $this->assertSession()->pageTextContains('full');
 
       $this->drupalGet('entity_test_converter/' . $entity->id());
-      $this->assertRaw($entity->label());
-      $this->assertRaw('full');
+      $this->assertSession()->pageTextContains($entity->label());
+      $this->assertSession()->pageTextContains('full');
 
       $this->drupalGet('entity_test_no_view_mode/' . $entity->id());
-      $this->assertRaw($entity->label());
-      $this->assertRaw('full');
+      $this->assertSession()->pageTextContains($entity->label());
+      $this->assertSession()->pageTextContains('full');
     }
 
     // Test viewing a revisionable entity.
@@ -76,8 +76,8 @@ public function testEntityViewController() {
     $entity_test_rev->isDefaultRevision(TRUE);
     $entity_test_rev->save();
     $this->drupalGet('entity_test_rev/' . $entity_test_rev->id() . '/revision/' . $entity_test_rev->revision_id->value . '/view');
-    $this->assertRaw($entity_test_rev->label());
-    $this->assertRaw($get_label_markup($entity_test_rev->label()));
+    $this->assertSession()->pageTextContains($entity_test_rev->label());
+    $this->assertSession()->responseContains($get_label_markup($entity_test_rev->label()));
 
     // As entity_test IDs must be integers, make sure requests for non-integer
     // IDs return a page not found error.
diff --git a/core/modules/system/tests/src/Functional/Form/ElementTest.php b/core/modules/system/tests/src/Functional/Form/ElementTest.php
index d5c9bd4f4de1523e5d78e8e3baaf21fccc6fcce9..dc11b26093609bf2de58a6c19c920d0fd5dae764 100644
--- a/core/modules/system/tests/src/Functional/Form/ElementTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php
@@ -52,10 +52,10 @@ public function testOptions() {
     }
 
     // Verify that the choices are admin filtered as expected.
-    $this->assertRaw("<em>Special Char</em>alert('checkboxes');");
-    $this->assertRaw("<em>Special Char</em>alert('radios');");
-    $this->assertRaw('<em>Bar - checkboxes</em>');
-    $this->assertRaw('<em>Bar - radios</em>');
+    $this->assertSession()->responseContains("<em>Special Char</em>alert('checkboxes');");
+    $this->assertSession()->responseContains("<em>Special Char</em>alert('radios');");
+    $this->assertSession()->responseContains('<em>Bar - checkboxes</em>');
+    $this->assertSession()->responseContains('<em>Bar - radios</em>');
 
     // Enable customized option sub-elements.
     $this->drupalGet('form-test/checkboxes-radios/customize');
@@ -178,7 +178,7 @@ public function testFormAutocomplete() {
     $this->drupalGet('form-test/autocomplete');
 
     // Make sure that the autocomplete library is added.
-    $this->assertRaw('core/misc/autocomplete.js');
+    $this->assertSession()->responseContains('core/misc/autocomplete.js');
 
     // Ensure that the user does have access to the autocompletion.
     $this->assertSession()->elementExists('xpath', '//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php
index 97467c81aaad1a3660fb7dea33b62ac6f40cf727..75097b3954b4798bc62f22c9f2c66a5da28e8509 100644
--- a/core/modules/system/tests/src/Functional/Form/FormTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormTest.php
@@ -232,7 +232,7 @@ public function testRequiredCheckboxesRadio() {
     // Verify that no error message is displayed when all required fields are
     // filled.
     $this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "error")]');
-    $this->assertRaw("The form_test_validate_required_form form was submitted successfully.");
+    $this->assertSession()->pageTextContains("The form_test_validate_required_form form was submitted successfully.");
   }
 
   /**
@@ -367,7 +367,7 @@ public function testRequiredTextfieldNoTitle() {
     $this->submitForm($edit, 'Submit');
     // Verify that no error input form element class is present.
     $this->assertSession()->elementNotExists('xpath', '//input[contains(@class, "error")]');
-    $this->assertRaw("The form_test_validate_required_form_no_title form was submitted successfully.");
+    $this->assertSession()->pageTextContains("The form_test_validate_required_form_no_title form was submitted successfully.");
   }
 
   /**
@@ -659,7 +659,7 @@ public function testNumber() {
           // Check if the error exists on the page, if the current message ID is
           // expected. Otherwise ensure that the error message is not present.
           if ($id === $error) {
-            $this->assertRaw(new FormattableMarkup($message, $placeholders));
+            $this->assertSession()->responseContains(new FormattableMarkup($message, $placeholders));
           }
           else {
             $this->assertSession()->responseNotContains(new FormattableMarkup($message, $placeholders));
diff --git a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
index 1d2e31ae7c7c5186374dc9c630da783d937b3530..3dee461407e31c2e326f6cc67fc145bb4aba8b40 100644
--- a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
@@ -385,7 +385,7 @@ public function testBreadCrumbs() {
 
     // Ensure that the breadcrumb is safe against XSS.
     $this->drupalGet('menu-test/breadcrumb1/breadcrumb2/breadcrumb3');
-    $this->assertRaw('<script>alert(12);</script>');
+    $this->assertSession()->responseContains('<script>alert(12);</script>');
     $this->assertSession()->assertEscaped('<script>alert(123);</script>');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
index 249a45c6bfac566a281b1fff945d2d2eac13b26e..2208cf5b19efdc2fd24717b34b3004b0db23be99 100644
--- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
@@ -199,7 +199,7 @@ protected function doTestExoticPath() {
       // cSpell:disable-next-line
       "éøïвβ中國書۞";
     $this->drupalGet($path);
-    $this->assertRaw('This is the menuTestCallback content.');
+    $this->assertSession()->pageTextContains('This is the menuTestCallback content.');
     $this->assertSession()->pageTextNotContains('The website encountered an unexpected error. Please try again later.');
   }
 
@@ -270,7 +270,7 @@ public function testThemeIntegration() {
   protected function doTestThemeCallbackAdministrative() {
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
     $this->assertSession()->pageTextContains('Active theme: seven. Actual theme: seven.');
-    $this->assertRaw('seven/css/base/elements.css');
+    $this->assertSession()->responseContains('seven/css/base/elements.css');
   }
 
   /**
@@ -283,7 +283,7 @@ protected function doTestThemeCallbackMaintenanceMode() {
     // we expect the theme callback system to be bypassed entirely.
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
     // Check that the maintenance theme's CSS appears on the page.
-    $this->assertRaw('bartik/css/base/elements.css');
+    $this->assertSession()->responseContains('bartik/css/base/elements.css');
 
     // An administrator, however, should continue to see the requested theme.
     $admin_user = $this->drupalCreateUser(['access site in maintenance mode']);
@@ -291,7 +291,7 @@ protected function doTestThemeCallbackMaintenanceMode() {
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
     $this->assertSession()->pageTextContains('Active theme: seven. Actual theme: seven.');
     // Check that the administrative theme's CSS appears on the page.
-    $this->assertRaw('seven/css/base/elements.css');
+    $this->assertSession()->responseContains('seven/css/base/elements.css');
 
     $this->container->get('state')->set('system.maintenance_mode', FALSE);
   }
@@ -304,7 +304,7 @@ protected function doTestThemeCallbackOptionalTheme() {
     $this->drupalGet('menu-test/theme-callback/use-test-theme');
     $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.');
     // Check that the default theme's CSS appears on the page.
-    $this->assertRaw('bartik/css/base/elements.css');
+    $this->assertSession()->responseContains('bartik/css/base/elements.css');
 
     // Now install the theme and request it again.
     /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
@@ -314,7 +314,7 @@ protected function doTestThemeCallbackOptionalTheme() {
     $this->drupalGet('menu-test/theme-callback/use-test-theme');
     $this->assertSession()->pageTextContains('Active theme: test_theme. Actual theme: test_theme.');
     // Check that the optional theme's CSS appears on the page.
-    $this->assertRaw('test_theme/kitten.css');
+    $this->assertSession()->responseContains('test_theme/kitten.css');
 
     $theme_installer->uninstall(['test_theme']);
   }
@@ -326,7 +326,7 @@ protected function doTestThemeCallbackFakeTheme() {
     $this->drupalGet('menu-test/theme-callback/use-fake-theme');
     $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.');
     // Check that the default theme's CSS appears on the page.
-    $this->assertRaw('bartik/css/base/elements.css');
+    $this->assertSession()->responseContains('bartik/css/base/elements.css');
   }
 
   /**
@@ -336,7 +336,7 @@ protected function doTestThemeCallbackNoThemeRequested() {
     $this->drupalGet('menu-test/theme-callback/no-theme-requested');
     $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.');
     // Check that the default theme's CSS appears on the page.
-    $this->assertRaw('bartik/css/base/elements.css');
+    $this->assertSession()->responseContains('bartik/css/base/elements.css');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
index b30550613cbc75d6a1c9a051ea7999fad5a7549b..7ec785f3f5919e688d1931ae4e8672497d1def4b 100644
--- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php
+++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
@@ -101,7 +101,7 @@ public function testIncompatibleCoreVersionDependency() {
    */
   public function testIncompatiblePhpVersionDependency() {
     $this->drupalGet('admin/modules');
-    $this->assertRaw('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.');
+    $this->assertSession()->pageTextContains('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.');
     $this->assertSession()->fieldDisabled('modules[system_incompatible_php_version_test][enable]');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
index c02869a668df80c07283f0460f6d008524b34ce2..0fbb0fc20208495c642b9b41137ca24318858deb 100644
--- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php
+++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
@@ -75,7 +75,7 @@ public function testUninstallPage() {
 
     // Be sure labels are rendered properly.
     // @see regression https://www.drupal.org/node/2512106
-    $this->assertRaw('<label for="edit-uninstall-node" class="module-name table-filter-text-source">Node</label>');
+    $this->assertSession()->responseContains('<label for="edit-uninstall-node" class="module-name table-filter-text-source">Node</label>');
 
     $this->assertSession()->pageTextContains('The following reason prevents Node from being uninstalled:');
     $this->assertSession()->pageTextContains('There is content for the entity type: Content');
@@ -114,7 +114,7 @@ public function testUninstallPage() {
       $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
       // Add h3's since the entity type label is often repeated in the entity
       // labels.
-      $this->assertRaw('<h3>' . $entity_type->getLabel() . '</h3>');
+      $this->assertSession()->responseContains('<h3>' . $entity_type->getLabel() . '</h3>');
     }
 
     // Set a unique cache entry to be able to test whether all caches are
diff --git a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
index 39db03a38700836deaa63918b18b1207a7ac6cf0..76e7e39fe9bb0c82fd2a42677ba80347c72b8516 100644
--- a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
+++ b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
@@ -37,19 +37,19 @@ public function testUpcasting() {
     // paramconverter_test/test_user_node_foo/{user}/{node}/{foo}
     $this->drupalGet("paramconverter_test/test_user_node_foo/" . $user->id() . '/' . $node->id() . "/$foo");
     // Verify user and node upcast by entity name.
-    $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: $foo");
+    $this->assertSession()->pageTextContains("user: {$user->label()}, node: {$node->label()}, foo: $foo");
 
     // paramconverter_test/test_node_user_user/{node}/{foo}/{user}
     // options.parameters.foo.type = entity:user
     $this->drupalGet("paramconverter_test/test_node_user_user/" . $node->id() . "/" . $user->id() . "/" . $user->id());
     // Verify foo converted to user as well.
-    $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}");
+    $this->assertSession()->pageTextContains("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}");
 
     // paramconverter_test/test_node_node_foo/{user}/{node}/{foo}
     // options.parameters.user.type = entity:node
     $this->drupalGet("paramconverter_test/test_node_node_foo/" . $node->id() . "/" . $node->id() . "/$foo");
     // Verify that user is upcast to node (rather than to user).
-    $this->assertRaw("user: {$node->label()}, node: {$node->label()}, foo: $foo");
+    $this->assertSession()->pageTextContains("user: {$node->label()}, node: {$node->label()}, foo: $foo");
   }
 
   /**
@@ -61,7 +61,7 @@ public function testSameTypes() {
     // paramconverter_test/node/{node}/set/parent/{parent}
     // options.parameters.parent.type = entity:node
     $this->drupalGet("paramconverter_test/node/" . $node->id() . "/set/parent/" . $parent->id());
-    $this->assertRaw("Setting '" . $parent->getTitle() . "' as parent of '" . $node->getTitle() . "'.");
+    $this->assertSession()->pageTextContains("Setting '" . $parent->getTitle() . "' as parent of '" . $node->getTitle() . "'.");
   }
 
   /**
@@ -82,9 +82,9 @@ public function testEntityLanguage() {
     $translation->setTitle('Deutscher Titel')->save();
 
     $this->drupalGet("/paramconverter_test/node/" . $node->id() . "/test_language");
-    $this->assertRaw("English label");
+    $this->assertSession()->pageTextContains("English label");
     $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", ['language' => $language]);
-    $this->assertRaw("Deutscher Titel");
+    $this->assertSession()->pageTextContains("Deutscher Titel");
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php b/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
index a7bebf645f7d9220650fcd083c3f3646505cd52a..c437115c6d32465f2cf0d7c6924639f15a4064cb 100644
--- a/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
+++ b/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
@@ -31,8 +31,8 @@ public function testPageDisplayVariantSelectionEvent() {
     // was passed correctly. If the configuration wasn't passed, we'd get an
     // error page here.
     $this->drupalGet('<front>');
-    $this->assertRaw('A very important, required value.');
-    $this->assertRaw('Explicitly passed in context.');
+    $this->assertSession()->pageTextContains('A very important, required value.');
+    $this->assertSession()->pageTextContains('Explicitly passed in context.');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'custom_cache_tag');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php b/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
index ad2f9774fed0c3f3b0d42e5119c153680a70d658..6d792472ff1959b3fac11b5884db023599b816d3 100644
--- a/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
+++ b/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
@@ -43,7 +43,7 @@ public function testUrlBubbleableMetadataBubbling() {
     $url = Url::fromRoute('cache_test.url_bubbling');
     $this->drupalGet($url);
     $this->assertCacheContext('url.site');
-    $this->assertRaw($url->setAbsolute()->toString());
+    $this->assertSession()->responseContains($url->setAbsolute()->toString());
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
index 4f8937388ed0040105d7ac3d1f482b6357269547..016f9e46caa93d331f59e56db2e5eca013ce02ff 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
@@ -40,7 +40,7 @@ public function testPermissionAccess() {
     $this->drupalGet('router_test/test7');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->responseNotContains('Access denied');
-    $this->assertRaw('test7text');
+    $this->assertSession()->pageTextContains('test7text');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
index d00a2f5bda633fa6e0768112c0f84e4e5839c44e..945cabddb3b97201aba6c8f2c922d2cdd31c1afd 100644
--- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php
+++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
@@ -37,7 +37,7 @@ public function testFinishResponseSubscriber() {
 
     // Confirm that the router can get to a controller.
     $this->drupalGet('router_test/test1');
-    $this->assertRaw('test1');
+    $this->assertSession()->pageTextContains('test1');
     $session = $this->getSession();
 
     // Check expected headers from FinishResponseSubscriber.
@@ -48,7 +48,7 @@ public function testFinishResponseSubscriber() {
     $this->assertSession()->responseHeaderDoesNotExist('Vary');
 
     $this->drupalGet('router_test/test2');
-    $this->assertRaw('test2');
+    $this->assertSession()->pageTextContains('test2');
     // Check expected headers from FinishResponseSubscriber.
     $headers = $session->getResponseHeaders();
     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Contexts', implode(' ', $expected_cache_contexts));
@@ -56,7 +56,7 @@ public function testFinishResponseSubscriber() {
     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Max-Age', '-1 (Permanent)');
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>');
+    $this->assertSession()->responseContains('</html>');
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
     $this->assertSession()->responseNotMatches('#</body>.*</body>#s');
@@ -120,22 +120,22 @@ public function testDuplicateRoutePaths() {
     // @see \Drupal\Core\Routing\RouteProvider::getRoutesByPath()
     $this->drupalGet('router-test/duplicate-path2');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('router_test.two_duplicate1');
+    $this->assertSession()->responseContains('router_test.two_duplicate1');
 
     // Tests three routes with same the path. One of the routes the path has a
     // different case.
     $this->drupalGet('router-test/case-sensitive-duplicate-path3');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('router_test.case_sensitive_duplicate1');
+    $this->assertSession()->responseContains('router_test.case_sensitive_duplicate1');
     // While case-insensitive matching works, exact matches are preferred.
     $this->drupalGet('router-test/case-sensitive-Duplicate-PATH3');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('router_test.case_sensitive_duplicate2');
+    $this->assertSession()->responseContains('router_test.case_sensitive_duplicate2');
     // Test that case-insensitive matching works, falling back to the first
     // route defined.
     $this->drupalGet('router-test/case-sensitive-Duplicate-Path3');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('router_test.case_sensitive_duplicate1');
+    $this->assertSession()->responseContains('router_test.case_sensitive_duplicate1');
   }
 
   /**
@@ -147,12 +147,12 @@ public function testControllerPlaceholders() {
     foreach ($values as $value) {
       $this->drupalGet('router_test/test3/' . $value);
       $this->assertSession()->statusCodeEquals(200);
-      $this->assertRaw($value);
+      $this->assertSession()->pageTextContains($value);
     }
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>');
+    $this->assertSession()->responseContains('</html>');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -165,11 +165,11 @@ public function testControllerPlaceholders() {
   public function testControllerPlaceholdersDefaultValues() {
     $this->drupalGet('router_test/test4');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('narf');
+    $this->assertSession()->pageTextContains('narf');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>');
+    $this->assertSession()->responseContains('</html>');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -182,11 +182,11 @@ public function testControllerPlaceholdersDefaultValues() {
   public function testControllerPlaceholdersDefaultValuesProvided() {
     $this->drupalGet('router_test/test4/barf');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('barf');
+    $this->assertSession()->pageTextContains('barf');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>');
+    $this->assertSession()->responseContains('</html>');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -202,7 +202,7 @@ public function testDynamicRoutes() {
     // Test the altered route.
     $this->drupalGet('router_test/test6');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('test5');
+    $this->assertSession()->pageTextContains('test5');
   }
 
   /**
@@ -211,11 +211,11 @@ public function testDynamicRoutes() {
   public function testControllerResolutionPage() {
     $this->drupalGet('/router_test/test10');
 
-    $this->assertRaw('abcde');
+    $this->assertSession()->pageTextContains('abcde');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>');
+    $this->assertSession()->responseContains('</html>');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style. This test verifies that is not happening.
@@ -294,7 +294,7 @@ public function testControllerResolutionAjax() {
 
     $this->assertSession()->responseHeaderEquals('Content-Type', 'application/json');
 
-    $this->assertRaw('abcde');
+    $this->assertSession()->pageTextContains('abcde');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php
index bd2b924f41f14180ff170ffac763e07a062eba81..b07b8cb55b97df78524db2008434778f8d498512 100644
--- a/core/modules/system/tests/src/Functional/Session/SessionTest.php
+++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php
@@ -316,7 +316,7 @@ public function testEmptySessionID() {
     $this->mink->resetSessions();
     $this->drupalGet('session-test/id-from-cookie');
     // Verify that session ID is blank as sent from cookie header.
-    $this->assertRaw("session_id:\n");
+    $this->assertSession()->responseContains("session_id:\n");
     // Assert that we have an anonymous session now.
     $this->drupalGet('session-test/is-logged-in');
     $this->assertSession()->statusCodeEquals(403);
diff --git a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
index 17a5343bb68192ead6dc62e2d1909a4cbe546a0d..c06d93aa1f46ad9f4b444ffb83e26cd915379768 100644
--- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
+++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\system\Functional\System;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
 use Drupal\user\RoleInterface;
@@ -72,7 +71,7 @@ public function testAccessDenied() {
     ];
     $this->drupalGet('admin/config/system/site-information');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_403']]));
+    $this->assertSession()->pageTextContains("The path '{$edit['site_403']}' has to start with a slash.");
 
     // Use a custom 403 page.
     $edit = [
diff --git a/core/modules/system/tests/src/Functional/System/AdminMetaTagTest.php b/core/modules/system/tests/src/Functional/System/AdminMetaTagTest.php
index 82dd89780cbb85ca2ebcfc101de707e8f8534fa8..187a82c9857fc9e261c765af04cd55541b1d66d8 100644
--- a/core/modules/system/tests/src/Functional/System/AdminMetaTagTest.php
+++ b/core/modules/system/tests/src/Functional/System/AdminMetaTagTest.php
@@ -23,7 +23,7 @@ public function testMetaTag() {
     list($version,) = explode('.', \Drupal::VERSION);
     $string = '<meta name="Generator" content="Drupal ' . $version . ' (https://www.drupal.org)" />';
     $this->drupalGet('node');
-    $this->assertRaw($string);
+    $this->assertSession()->responseContains($string);
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
index 295466bc2f9b293b184598d21437b6b5de3d578a..3bdb1922437c4e00792eb652b8ae983b61529a4f 100644
--- a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
@@ -36,7 +36,7 @@ protected function setUp(): void {
   public function testDefaultMetaTagsExist() {
     $this->drupalGet('');
     foreach ($this->defaultMetaTags as $name => $metatag) {
-      $this->assertRaw($metatag);
+      $this->assertSession()->responseContains($metatag);
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
index 7f27c054e0318e5a0881099cda3715cf8f457942..5d97125dd57cc8534a2a151380df1ec00cc2ea5a 100644
--- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
+++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
@@ -55,9 +55,9 @@ public function testErrorHandler() {
     $this->assertErrorMessage($error_notice);
     $this->assertErrorMessage($error_warning);
     $this->assertErrorMessage($error_user_notice);
-    $this->assertRaw('<pre class="backtrace">');
+    $this->assertSession()->responseContains('<pre class="backtrace">');
     // Ensure we are escaping but not double escaping.
-    $this->assertRaw('&amp;');
+    $this->assertSession()->responseContains('&amp;');
     $this->assertSession()->responseNotContains('&amp;amp;');
 
     // Set error reporting to display verbose notices.
@@ -131,7 +131,7 @@ public function testExceptionHandler() {
     // error message.
     $this->assertSession()->pageTextContains($error_pdo_exception['@message']);
     $error_details = new FormattableMarkup('in %function (line ', $error_pdo_exception);
-    $this->assertRaw($error_details);
+    $this->assertSession()->responseContains($error_details);
     $this->drupalGet('error-test/trigger-renderer-exception');
     $this->assertSession()->statusCodeEquals(500);
     $this->assertErrorMessage($error_renderer_exception);
@@ -153,7 +153,7 @@ public function testExceptionHandler() {
    */
   public function assertErrorMessage(array $error) {
     $message = new FormattableMarkup('%type: @message in %function (line ', $error);
-    $this->assertRaw($message);
+    $this->assertSession()->responseContains($message);
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/System/FrontPageTest.php b/core/modules/system/tests/src/Functional/System/FrontPageTest.php
index 7164f3365a15f05fe9c6e11eeac92eb824c16b99..d350dfe2d88b970bc0649d4e3548e61d9e335287 100644
--- a/core/modules/system/tests/src/Functional/System/FrontPageTest.php
+++ b/core/modules/system/tests/src/Functional/System/FrontPageTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\system\Functional\System;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -78,7 +77,7 @@ public function testDrupalFrontPage() {
     $edit = ['site_frontpage' => $this->nodePath];
     $this->drupalGet('admin/config/system/site-information');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']]));
+    $this->assertSession()->pageTextContains("The path '{$edit['site_frontpage']}' has to start with a slash.");
 
     // Change the front page to a valid path.
     $edit['site_frontpage'] = '/' . $this->nodePath;
diff --git a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
index 634c3ebe964ee66ed558fcfcace8e45aea9cdd11..47afe0917d63bf8d8ef29f768e147a59c8cdf21f 100644
--- a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
+++ b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\system\Functional\System;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Tests\BrowserTestBase;
 use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
 use Drupal\user\RoleInterface;
@@ -56,7 +55,7 @@ public function testPageNotFound() {
     ];
     $this->drupalGet('admin/config/system/site-information');
     $this->submitForm($edit, 'Save configuration');
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
+    $this->assertSession()->pageTextContains("The path '{$edit['site_404']}' has to start with a slash.");
 
     // Use a custom 404 page.
     $edit = [
diff --git a/core/modules/system/tests/src/Functional/System/PageTitleTest.php b/core/modules/system/tests/src/Functional/System/PageTitleTest.php
index 5768af90b1c6450ed2d5c2e9451e0364f4cee0a8..ed7b2340120af6ba5fac59fcb9aee8b32da8440f 100644
--- a/core/modules/system/tests/src/Functional/System/PageTitleTest.php
+++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php
@@ -101,13 +101,13 @@ public function testTitleXSS() {
     $this->assertSession()->responseNotContains($title);
     // Add </title> to make sure we're checking the title tag, rather than the
     // first 'heading' on the page.
-    $this->assertRaw($title_filtered . '</title>');
+    $this->assertSession()->responseContains($title_filtered . '</title>');
 
     // Test the slogan.
     // Check the unfiltered version of the slogan is missing.
     $this->assertSession()->responseNotContains($slogan);
     // Check for the filtered version of the slogan.
-    $this->assertRaw($slogan_filtered);
+    $this->assertSession()->responseContains($slogan_filtered);
   }
 
   /**
@@ -166,10 +166,10 @@ public function testRoutingTitle() {
     // controller does not escape them.
     $this->drupalGet('test-page-cached-controller');
     $this->assertSession()->titleEquals('Cached title | Drupal');
-    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
+    $this->assertSession()->responseContains(Html::escape('<span>Cached title</span>') . '</h1>');
     $this->drupalGet('test-page-cached-controller');
     $this->assertSession()->titleEquals('Cached title | Drupal');
-    $this->assertRaw(Html::escape('<span>Cached title</span>') . '</h1>');
+    $this->assertSession()->responseContains(Html::escape('<span>Cached title</span>') . '</h1>');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php b/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php
index 8c8fccafa166185d279628aae4db8c96f62d09b2..2059714e9464ead60e02e2bde7de37bc3581a719 100644
--- a/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php
+++ b/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php
@@ -54,7 +54,7 @@ public function testShutdownFunctions() {
       // Make sure exceptions displayed through
       // \Drupal\Core\Utility\Error::renderExceptionSafe() are correctly
       // escaped.
-      $this->assertRaw('Drupal is &lt;blink&gt;awesome&lt;/blink&gt;.');
+      $this->assertSession()->responseContains('Drupal is &lt;blink&gt;awesome&lt;/blink&gt;.');
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
index 6b9b6316e180251afa9a73ac197ca7b2185e4de9..1400fb0561ee27a954620a77ed4659beff7e10b9 100644
--- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
+++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
@@ -166,7 +166,7 @@ public function testNonHtmlRequest() {
     foreach ($formats as $format) {
       $this->drupalGet('<front>', ['query' => ['_format' => $format]]);
       $this->assertSession()->statusCodeEquals(503);
-      $this->assertRaw('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
+      $this->assertSession()->pageTextContains('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
       $this->assertSession()->responseHeaderEquals('Content-Type', 'text/plain; charset=UTF-8');
     }
   }
diff --git a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
index 8f42feb75a66e99dd72c5519dec7b8e817e975a8..376ae42482ac22b7f3b39b11b92fd1947686c7e6 100644
--- a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
+++ b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
@@ -57,12 +57,12 @@ public function testFileTransferHooks() {
     $this->assertSession()->pageTextNotContains('It appears you have reached this page in error.');
     $this->assertSession()->pageTextContains('To continue, provide your server connection details');
     // Make sure we see the new connection method added by system_test.
-    $this->assertRaw('System Test FileTransfer');
+    $this->assertSession()->pageTextContains('System Test FileTransfer');
     // Make sure the settings form callback works.
     $this->assertSession()->pageTextContains('System Test Username');
     // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets as
     // expected to the first page of the authorize.php script.
-    $this->assertRaw('core/misc/states.js');
+    $this->assertSession()->responseContains('core/misc/states.js');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php
index 39b93b19939e23b8198338418fb52e0090533d85..ca1c94eaf14ad00c496b912cf02173fefc59eedf 100644
--- a/core/modules/system/tests/src/Functional/System/ThemeTest.php
+++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php
@@ -290,19 +290,19 @@ public function testAdministrationTheme() {
 
     // Check that the administration theme is used on an administration page.
     $this->drupalGet('admin/config');
-    $this->assertRaw('core/themes/seven');
+    $this->assertSession()->responseContains('core/themes/seven');
 
     // Check that the site default theme used on node page.
     $this->drupalGet('node/' . $this->node->id());
-    $this->assertRaw('core/themes/classy');
+    $this->assertSession()->responseContains('core/themes/classy');
 
     // Check that the administration theme is used on the add content page.
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/seven');
+    $this->assertSession()->responseContains('core/themes/seven');
 
     // Check that the administration theme is used on the edit content page.
     $this->drupalGet('node/' . $this->node->id() . '/edit');
-    $this->assertRaw('core/themes/seven');
+    $this->assertSession()->responseContains('core/themes/seven');
 
     // Disable the admin theme on the node admin pages.
     $edit = [
@@ -313,7 +313,7 @@ public function testAdministrationTheme() {
 
     // Check that the administration theme is used on an administration page.
     $this->drupalGet('admin/config');
-    $this->assertRaw('core/themes/seven');
+    $this->assertSession()->responseContains('core/themes/seven');
 
     // Ensure that the admin theme is also visible on the 403 page.
     $normal_user = $this->drupalCreateUser(['view the administration theme']);
@@ -321,12 +321,12 @@ public function testAdministrationTheme() {
     // Check that the administration theme is used on an administration page.
     $this->drupalGet('admin/config');
     $this->assertSession()->statusCodeEquals(403);
-    $this->assertRaw('core/themes/seven');
+    $this->assertSession()->responseContains('core/themes/seven');
     $this->drupalLogin($this->adminUser);
 
     // Check that the site default theme used on the add content page.
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/classy');
+    $this->assertSession()->responseContains('core/themes/classy');
 
     // Reset to the default theme settings.
     $edit = [
@@ -338,11 +338,11 @@ public function testAdministrationTheme() {
 
     // Check that the site default theme used on administration page.
     $this->drupalGet('admin');
-    $this->assertRaw('core/themes/classy');
+    $this->assertSession()->responseContains('core/themes/classy');
 
     // Check that the site default theme used on the add content page.
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/classy');
+    $this->assertSession()->responseContains('core/themes/classy');
   }
 
   /**
@@ -432,7 +432,7 @@ public function testUninstallingThemes() {
     $this->submitForm($edit, 'Save configuration');
 
     // Check that seven can be uninstalled now.
-    $this->assertRaw('Uninstall Seven theme');
+    $this->assertSession()->responseContains('Uninstall Seven theme');
     // Check that the classy theme still cannot be uninstalled as it is a
     // base theme of bartik.
     $this->assertSession()->responseNotContains('Uninstall Classy theme');
@@ -441,7 +441,7 @@ public function testUninstallingThemes() {
     $this->clickLink('Set as default', 1);
 
     // Check that bartik can be uninstalled now.
-    $this->assertRaw('Uninstall Bartik theme');
+    $this->assertSession()->responseContains('Uninstall Bartik theme');
 
     // Check that the classy theme still can't be uninstalled as neither of its
     // base themes have been.
@@ -449,10 +449,10 @@ public function testUninstallingThemes() {
 
     // Uninstall each of the three themes starting with Bartik.
     $this->clickLink('Uninstall');
-    $this->assertRaw('The <em class="placeholder">Bartik</em> theme has been uninstalled');
+    $this->assertSession()->responseContains('The <em class="placeholder">Bartik</em> theme has been uninstalled');
     // Seven is the second in the list.
     $this->clickLink('Uninstall');
-    $this->assertRaw('The <em class="placeholder">Seven</em> theme has been uninstalled');
+    $this->assertSession()->responseContains('The <em class="placeholder">Seven</em> theme has been uninstalled');
 
     // Check that the classy theme still can't be uninstalled as it is hidden.
     $this->assertSession()->responseNotContains('Uninstall Classy theme');
diff --git a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
index fbe9819474b2596c05338d29231e96e96354dec4..da8fe199b8bc3c67c4b9e8728979633e72b04f11 100644
--- a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
@@ -42,7 +42,7 @@ public function testTwigVariableDataTypes() {
       ->save();
     $this->drupalGet('twig-theme-test/php-variables');
     foreach (_test_theme_twig_php_values() as $type => $value) {
-      $this->assertRaw('<li>' . $type . ': ' . $value['expected'] . '</li>');
+      $this->assertSession()->responseContains('<li>' . $type . ': ' . $value['expected'] . '</li>');
     }
   }
 
@@ -71,7 +71,7 @@ public function testTwigUrlGenerator() {
     $content = $this->getSession()->getPage()->getContent();
     $this->assertFalse(empty($content), 'Page content is not empty');
     foreach ($expected as $string) {
-      $this->assertRaw('<div>' . $string . '</div>');
+      $this->assertSession()->responseContains('<div>' . $string . '</div>');
     }
   }
 
@@ -105,7 +105,7 @@ public function testTwigLinkGenerator() {
     $content = $this->getSession()->getPage()->getContent();
     $this->assertFalse(empty($content), 'Page content is not empty');
     foreach ($expected as $string) {
-      $this->assertRaw('<div>' . $string . '</div>');
+      $this->assertSession()->responseContains('<div>' . $string . '</div>');
     }
   }
 
@@ -124,7 +124,7 @@ public function testTwigUrlToString() {
     $content = $this->getSession()->getPage()->getContent();
     $this->assertFalse(empty($content), 'Page content is not empty');
     foreach ($expected as $string) {
-      $this->assertRaw('<div>' . $string . '</div>');
+      $this->assertSession()->responseContains('<div>' . $string . '</div>');
     }
   }
 
@@ -136,7 +136,7 @@ public function testTwigFileUrls() {
     /** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
     $file_url_generator = \Drupal::service('file_url_generator');
     $filepath = $file_url_generator->generateString('core/modules/system/tests/modules/twig_theme_test/twig_theme_test.js');
-    $this->assertRaw('<div>file_url: ' . $filepath . '</div>');
+    $this->assertSession()->responseContains('<div>file_url: ' . $filepath . '</div>');
   }
 
   /**
@@ -144,7 +144,7 @@ public function testTwigFileUrls() {
    */
   public function testTwigAttachLibrary() {
     $this->drupalGet('/twig-theme-test/attach-library');
-    $this->assertRaw('ckeditor.js');
+    $this->assertSession()->responseContains('ckeditor.js');
   }
 
   /**
@@ -152,7 +152,7 @@ public function testTwigAttachLibrary() {
    */
   public function testRenderable() {
     $this->drupalGet('/twig-theme-test/renderable');
-    $this->assertRaw('<div>Example markup</div>');
+    $this->assertSession()->responseContains('<div>Example markup</div>');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Theme/FastTest.php b/core/modules/system/tests/src/Functional/Theme/FastTest.php
index ec6f3a9d38f9dd648e7d36dcc5fa2ce72f86d003..40475325869b0a5e3d2cf4381351625517e50342 100644
--- a/core/modules/system/tests/src/Functional/Theme/FastTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/FastTest.php
@@ -34,7 +34,7 @@ protected function setUp(): void {
   public function testUserAutocomplete() {
     $this->drupalLogin($this->account);
     $this->drupalGet('user/autocomplete', ['query' => ['q' => $this->account->getAccountName()]]);
-    $this->assertRaw($this->account->getAccountName());
+    $this->assertSession()->responseContains($this->account->getAccountName());
     $this->assertSession()->pageTextNotContains('registry initialized');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
index 2c8c5f9aad14b71519f3ef311ca605ae649fccee..d492ddc22850b6e7da9352030366565a1de64b2d 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
@@ -30,10 +30,10 @@ class ThemeEarlyInitializationTest extends BrowserTestBase {
   public function testRequestListener() {
     $this->drupalGet('theme-test/request-listener');
     // Verify that themed output generated in the request listener appears.
-    $this->assertRaw('Themed output generated in a KernelEvents::REQUEST listener');
+    $this->assertSession()->responseContains('Themed output generated in a KernelEvents::REQUEST listener');
     // Verify that the default theme's CSS still appears even though the theme
     // system was initialized early.
-    $this->assertRaw('classy/css/components/action-links.css');
+    $this->assertSession()->responseContains('classy/css/components/action-links.css');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
index 45de8f1efec81071afc2317839123ec9490d9a34..7442e53ecdcb1063aeff875e9967a3e84163a022 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php
@@ -49,7 +49,7 @@ public function testTwigExtensionFilter() {
     $this->drupalGet('twig-extension-test/filter');
     $this->assertSession()->pageTextContains('Every plant is not a mineral.');
     // Test safe_join filter.
-    $this->assertRaw('&lt;em&gt;will be escaped&lt;/em&gt;<br/><em>will be markup</em><br/><strong>will be rendered</strong>');
+    $this->assertSession()->responseContains('&lt;em&gt;will be escaped&lt;/em&gt;<br/><em>will be markup</em><br/><strong>will be rendered</strong>');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php
index c68c1c9d7a16612180a770acecc81d0605b39802..cb292abf31d76471cef865d0e907db5a90854d15 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php
@@ -148,15 +148,15 @@ protected function assertTwigTransTags() {
 
     // Assert that {{ token }} was successfully translated and prefixed
     // with "@".
-    $this->assertRaw('ESCAPEE: &amp;&quot;&lt;&gt;');
+    $this->assertSession()->responseContains('ESCAPEE: &amp;&quot;&lt;&gt;');
 
     // Assert that {{ token|placeholder }} was successfully translated and
     // prefixed with "%".
-    $this->assertRaw('PLAYSHOLDR: <em class="placeholder">&amp;&quot;&lt;&gt;</em>');
+    $this->assertSession()->responseContains('PLAYSHOLDR: <em class="placeholder">&amp;&quot;&lt;&gt;</em>');
 
     // Assert that {{ complex.tokens }} were successfully translated with
     // appropriate prefixes.
-    $this->assertRaw('DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;.');
+    $this->assertSession()->responseContains('DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;.');
 
     // Assert that {% trans %} with a context only msgid is excluded from
     // translation.
@@ -200,7 +200,7 @@ protected function installLanguages() {
         // Install the language in Drupal.
         $this->drupalGet('admin/config/regional/language/add');
         $this->submitForm($edit, 'Add custom language');
-        $this->assertRaw('"edit-languages-' . $langcode . '-weight"');
+        $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
 
         // Import the custom .po contents for the language.
         $filename = $file_system->tempnam('temporary://', "po_") . '.po';
diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php
index cf64b7d536056d4a4b0a4ac91fc972100a711ab6..f45012b3f2c0e11dba92dab4e0c230eb9617d5e8 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php
@@ -110,20 +110,20 @@ public function testUpdatedSite() {
     $this->assertSession()->pageTextContains('Test title');
     $this->assertSession()->pageTextContains('Test body');
     $this->assertSession()->checkboxChecked('edit-field-test-1-value');
-    $this->assertRaw('2015-08-16');
-    $this->assertRaw('test@example.com');
-    $this->assertRaw('drupal.org');
+    $this->assertSession()->responseContains('2015-08-16');
+    $this->assertSession()->responseContains('test@example.com');
+    $this->assertSession()->responseContains('drupal.org');
     $this->assertSession()->pageTextContains('0.1');
     $this->assertSession()->pageTextContains('0.2');
-    $this->assertRaw('+31612345678');
-    $this->assertRaw('+31612345679');
+    $this->assertSession()->responseContains('+31612345678');
+    $this->assertSession()->responseContains('+31612345679');
     $this->assertSession()->pageTextContains('Test Article - New title');
     $this->assertSession()->pageTextContains('test.txt');
     $this->assertSession()->pageTextContains('druplicon.small');
-    $this->assertRaw('General discussion');
+    $this->assertSession()->responseContains('General discussion');
     $this->assertSession()->pageTextContains('Test Article - New title');
     $this->assertSession()->pageTextContains('Test 1');
-    $this->assertRaw('0.01');
+    $this->assertSession()->responseContains('0.01');
     $this->drupalGet('node/8/edit');
     $this->submitForm([], 'Save (this translation)');
     $this->assertSession()->statusCodeEquals(200);
@@ -134,7 +134,7 @@ public function testUpdatedSite() {
     // Make sure the user page is correct.
     $this->drupalGet('user/3');
     $this->assertSession()->pageTextContains('usuario_test');
-    $this->assertRaw('druplicon.small');
+    $this->assertSession()->responseContains('druplicon.small');
     $this->assertSession()->pageTextContains('Test file field');
     $this->assertSession()->linkExists('test.txt');
 
@@ -155,14 +155,14 @@ public function testUpdatedSite() {
     $this->clickLink('Test Article - New title');
     $this->assertSession()->pageTextContains('Body');
     $this->assertSession()->pageTextContains('Tags');
-    $this->assertRaw('Text format');
+    $this->assertSession()->responseContains('Text format');
 
     // Make sure that users still exist.
     $this->drupalGet('admin/people');
     $this->assertSession()->pageTextContains('usuario_test');
     $this->assertSession()->pageTextContains('drupal');
     $this->drupalGet('user/1/edit');
-    $this->assertRaw('drupal@example.com');
+    $this->assertSession()->responseContains('drupal@example.com');
 
     // Make sure the content view works.
     $this->drupalGet('admin/content');
@@ -185,7 +185,7 @@ public function testUpdatedSite() {
 
     // Make sure our block is still translated.
     $this->drupalGet('admin/structure/block/manage/testblock/translate/es/edit');
-    $this->assertRaw('Test block spanish');
+    $this->assertSession()->responseContains('Test block spanish');
 
     // Make sure our custom text format exists.
     $this->drupalGet('admin/config/content/formats');
@@ -217,7 +217,7 @@ public function testUpdatedSite() {
     $this->clickLink('Admin');
     // Make sure the translation for the menu is still correct.
     $this->drupalGet('admin/structure/menu/manage/test-menu/translate/es/edit');
-    $this->assertRaw('Menu test');
+    $this->assertSession()->responseContains('Menu test');
     // Make sure our custom menu link exists.
     $this->drupalGet('admin/structure/menu/item/1/edit');
     $this->assertSession()->checkboxChecked('edit-enabled-value');
@@ -314,7 +314,7 @@ public function testUpdatedSite() {
     $this->assertSession()->pageTextContains('Test action');
     $this->drupalGet('admin/config/system/actions/configure/test_action');
     $this->assertSession()->fieldValueEquals('id', 'test_action');
-    $this->assertRaw('drupal.org');
+    $this->assertSession()->responseContains('drupal.org');
 
     // Make sure our ban still exists.
     $this->drupalGet('admin/config/people/ban');
@@ -341,7 +341,7 @@ public function testUpdatedSite() {
     $this->assertSession()->pageTextContains('Hello');
     $this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit');
     $this->assertSession()->pageTextContains('Hola');
-    $this->assertRaw('Test contact form Spanish');
+    $this->assertSession()->responseContains('Test contact form Spanish');
 
     // Make sure our modules are still enabled.
     $expected_enabled_modules = [
diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
index 25c5a89b15f12f56f967076415ad1561a84e0230..f97a2b61f6ada701b4b642b12171df17c1ced307 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
@@ -76,16 +76,16 @@ protected function doSelectionTest() {
   public function testPostUpdate() {
     $this->runUpdates();
 
-    $this->assertRaw('<h3>Update first</h3>');
-    $this->assertRaw('First update');
-    $this->assertRaw('<h3>Update second</h3>');
-    $this->assertRaw('Second update');
-    $this->assertRaw('<h3>Update test1</h3>');
-    $this->assertRaw('Test1 update');
-    $this->assertRaw('<h3>Update test0</h3>');
-    $this->assertRaw('Test0 update');
-    $this->assertRaw('<h3>Update test_batch</h3>');
-    $this->assertRaw('Test post update batches');
+    $this->assertSession()->responseContains('<h3>Update first</h3>');
+    $this->assertSession()->pageTextContains('First update');
+    $this->assertSession()->responseContains('<h3>Update second</h3>');
+    $this->assertSession()->pageTextContains('Second update');
+    $this->assertSession()->responseContains('<h3>Update test1</h3>');
+    $this->assertSession()->pageTextContains('Test1 update');
+    $this->assertSession()->responseContains('<h3>Update test0</h3>');
+    $this->assertSession()->pageTextContains('Test0 update');
+    $this->assertSession()->responseContains('<h3>Update test_batch</h3>');
+    $this->assertSession()->pageTextContains('Test post update batches');
 
     // Test state value set by each post update.
     $updates = [
diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
index 595a479e6949dc9498c7a29e0cdd7d0696706984..9cbee7c163eeb3221439432fd825653f1a6c0dfd 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
@@ -72,7 +72,7 @@ public function testUpdateHooks() {
     $this->drupalGet($this->updateUrl, ['external' => TRUE]);
     $this->updateRequirementsProblem();
     $this->clickLink('Continue');
-    $this->assertRaw('Schema version 8001.');
+    $this->assertSession()->pageTextContains('Schema version 8001.');
     // Run the update hooks.
     $this->clickLink('Apply pending updates');
     $this->checkForMetaRefresh();
diff --git a/core/modules/taxonomy/tests/src/Functional/RssTest.php b/core/modules/taxonomy/tests/src/Functional/RssTest.php
index 284f9f22b5e593bae0c1e762fd585d5ad776c07a..784df374750e79a06573b4da0dd091d3a3d5af94 100644
--- a/core/modules/taxonomy/tests/src/Functional/RssTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php
@@ -112,7 +112,7 @@ public function testTaxonomyRss() {
       'domain="' . $term1->toUrl('canonical', ['absolute' => TRUE])->toString() . '"',
       $term1->getName()
     );
-    $this->assertRaw($test_element);
+    $this->assertSession()->responseContains($test_element);
 
     // Test that the feed icon exists for the term.
     $this->drupalGet("taxonomy/term/{$term1->id()}");
@@ -139,7 +139,7 @@ public function testTaxonomyRss() {
     $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $raw_xml = '<title>' . $node->label() . '</title>';
     $this->drupalGet('taxonomy/term/all/feed');
-    $this->assertRaw($raw_xml);
+    $this->assertSession()->responseContains($raw_xml);
     // Unpublish the article and check that it is not shown in the feed.
     $node->setUnpublished()->save();
     $this->drupalGet('taxonomy/term/all/feed');
diff --git a/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php b/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
index 04d030f14844f0359059e39e0275fac95595ad90..cf011b157ef2f9b13c42d46da68a10a356ff7390 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
@@ -248,7 +248,7 @@ public function testTaxonomyTermHierarchyBreadcrumbs() {
     // Breadcrumbs are not rendered with a language, prevent the term
     // language from being added to the options.
     // Check that parent term link is displayed when viewing the node.
-    $this->assertRaw(Link::fromTextAndUrl($term2->getName(), $term2->toUrl('canonical', ['language' => NULL]))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl($term2->getName(), $term2->toUrl('canonical', ['language' => NULL]))->toString());
   }
 
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php
index e1107dfe84c46a9ab3e4b164c4116044ab720693..e41a918cfe02dbbdc1ba4628c2a2a7a0a17412d7 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php
@@ -267,7 +267,7 @@ public function testNodeTermCreationAndDeletion() {
 
     // Verify the placeholder is there.
     $this->drupalGet('node/add/article');
-    $this->assertRaw('placeholder="Start typing here."');
+    $this->assertSession()->responseContains('placeholder="Start typing here."');
 
     // Preview and verify the terms appear but are not created.
     $this->submitForm($edit, 'Preview');
@@ -357,7 +357,7 @@ public function testTermInterface() {
     $this->clickLink('Edit');
 
     // Verify that the randomly generated term is present.
-    $this->assertRaw($edit['name[0][value]']);
+    $this->assertSession()->pageTextContains($edit['name[0][value]']);
     $this->assertSession()->pageTextContains($edit['description[0][value]']);
 
     $edit = [
@@ -618,9 +618,9 @@ public function testReSavingTags() {
     // Check that the term is displayed when editing and saving the node with no
     // changes.
     $this->clickLink('Edit');
-    $this->assertRaw($term->getName());
+    $this->assertSession()->responseContains($term->getName());
     $this->submitForm([], 'Save');
-    $this->assertRaw($term->getName());
+    $this->assertSession()->responseContains($term->getName());
   }
 
   /**
diff --git a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
index 985b1ce2bbb6c97c313b7b59a9bd949a64c9fcc9..532164353a55284f4923be3aa398b8d44705fe6a 100644
--- a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
@@ -44,20 +44,20 @@ public function testTaxonomyTermThemes() {
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
     // Check that the administrative theme's CSS appears on the page for adding
     // a taxonomy term.
-    $this->assertRaw('seven/css/base/elements.css');
+    $this->assertSession()->responseContains('seven/css/base/elements.css');
 
     // Viewing a taxonomy term should use the default theme.
     $term = $this->createTerm($vocabulary);
     $this->drupalGet('taxonomy/term/' . $term->id());
     // Check that the default theme's CSS appears on the page for viewing
     // a taxonomy term.
-    $this->assertRaw('bartik/css/base/elements.css');
+    $this->assertSession()->responseContains('bartik/css/base/elements.css');
 
     // Editing a taxonomy term should use the same theme as adding one.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
     // Check that the administrative theme's CSS appears on the page for editing
     // a taxonomy term.
-    $this->assertRaw('seven/css/base/elements.css');
+    $this->assertSession()->responseContains('seven/css/base/elements.css');
   }
 
 }
diff --git a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
index 4e0a9b3aa21cbb44aa197d6e03cad88d1eca68ad..fcb5a4c0f0e452bfb6c90d3d59404177bd20e15d 100644
--- a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
+++ b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
@@ -89,7 +89,7 @@ protected function setUp(): void {
   public function testTelephoneWidget() {
     $this->drupalGet('node/add/article');
     $this->assertSession()->fieldValueEquals("field_telephone[0][value]", '');
-    $this->assertRaw('placeholder="123-456-7890"');
+    $this->assertSession()->responseContains('placeholder="123-456-7890"');
   }
 
   /**
@@ -108,7 +108,7 @@ public function testTelephoneFormatter($input, $expected) {
 
     $this->drupalGet('node/add/article');
     $this->submitForm($edit, 'Save');
-    $this->assertRaw('<a href="tel:' . $expected . '">');
+    $this->assertSession()->responseContains('<a href="tel:' . $expected . '">');
   }
 
   /**
diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
index 5813f1f348b8b317e4958fee08cb891d8d96d8d4..65975d1e25ba4d454ce32fdb0542379246d3e049 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
@@ -104,7 +104,7 @@ protected function setUp(): void {
     $this->assertSession()->statusCodeEquals(200);
 
     // Assert that the toolbar is present in the HTML.
-    $this->assertRaw('id="toolbar-administration"');
+    $this->assertSession()->responseContains('id="toolbar-administration"');
 
     // Store the adminUser admin menu subtrees hash for comparison later.
     $this->hash = $this->getSubtreesHash();
@@ -196,7 +196,7 @@ public function testUserRoleUpdateSubtreesHashCacheClear() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Assert that the toolbar is present in the HTML.
-    $this->assertRaw('id="toolbar-administration"');
+    $this->assertSession()->responseContains('id="toolbar-administration"');
 
     $admin_user_2_hash = $this->getSubtreesHash();
 
@@ -206,7 +206,7 @@ public function testUserRoleUpdateSubtreesHashCacheClear() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Assert that the toolbar is present in the HTML.
-    $this->assertRaw('id="toolbar-administration"');
+    $this->assertSession()->responseContains('id="toolbar-administration"');
 
     $this->hash = $this->getSubtreesHash();
 
@@ -304,7 +304,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() {
     t($name, [], ['langcode' => $langcode]);
     // Reset locale cache.
     $this->container->get('string_translation')->reset();
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
     // Verify that the test language was added.
     $this->assertSession()->pageTextContains($name);
 
@@ -433,7 +433,7 @@ public function testExternalLink() {
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertSession()->pageTextContains('External URL');
     // Ensure the description is escaped as expected.
-    $this->assertRaw('title="External URL &amp; escaped"');
+    $this->assertSession()->responseContains('title="External URL &amp; escaped"');
   }
 
   /**
diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
index fee6f2666bb2e5f51994d32910a00fb5a95178d2..d04042a9ef666ba70a027f79ba7ce4cea63b41da 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php
@@ -46,19 +46,19 @@ public function testHookToolbar() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Assert that the toolbar is present in the HTML.
-    $this->assertRaw('id="toolbar-administration"');
+    $this->assertSession()->responseContains('id="toolbar-administration"');
 
     // Assert that the tab registered by toolbar_test is present.
-    $this->assertRaw('id="toolbar-tab-testing"');
+    $this->assertSession()->responseContains('id="toolbar-tab-testing"');
 
     // Assert that the tab item descriptions are present.
-    $this->assertRaw('title="Test tab"');
+    $this->assertSession()->responseContains('title="Test tab"');
 
     // Assert that the tray registered by toolbar_test is present.
-    $this->assertRaw('id="toolbar-tray-testing"');
+    $this->assertSession()->responseContains('id="toolbar-tray-testing"');
 
     // Assert that tray item descriptions are present.
-    $this->assertRaw('title="Test link 1 title"');
+    $this->assertSession()->responseContains('title="Test link 1 title"');
   }
 
 }
diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php
index 0ac9a7c71215cca2648a44bcabf8888c8872831e..4c01a0d06dc14ebe3efd23972e4d3812380cfcf5 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -237,7 +237,7 @@ public function testTrackerUser() {
     Cache::invalidateTags(['rendered']);
     $this->drupalGet('user/' . $this->user->id() . '/activity');
     $this->assertSession()->assertNoEscaped('<em>' . $this->user->id() . '</em>');
-    $this->assertRaw('<em>' . $this->user->id() . '</em>');
+    $this->assertSession()->responseContains('<em>' . $this->user->id() . '</em>');
   }
 
   /**
diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php
index 38430d8fa8f484f7e0ec6554df56a895af1e3434..e9ea3f7fc00f5b5b22b1fddc4980aed71b3136b0 100644
--- a/core/modules/update/tests/src/Functional/UpdateContribTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -69,7 +69,7 @@ public function testNoReleasesAvailable() {
     // Cannot use $this->standardTests() because we need to check for the
     // 'No available releases found' string.
     $this->assertSession()->responseContains('<h3>Drupal core</h3>');
-    $this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
     $this->assertSession()->pageTextContains('Up to date');
     $this->assertSession()->responseContains('<h3>Modules</h3>');
     $this->assertSession()->pageTextNotContains('Update available');
@@ -106,7 +106,7 @@ public function testUpdateContribBasic() {
     $this->assertSession()->pageTextContains('Up to date');
     $this->assertSession()->responseContains('<h3>Modules</h3>');
     $this->assertSession()->pageTextNotContains('Update available');
-    $this->assertRaw($project_link);
+    $this->assertSession()->responseContains($project_link);
 
     // Since aaa_update_test is installed the fact it is hidden and in the
     // Testing package means it should not appear.
@@ -129,7 +129,7 @@ public function testUpdateContribBasic() {
         'aaa_update_test' => '1_0',
       ]
     );
-    $this->assertRaw($project_link);
+    $this->assertSession()->responseContains($project_link);
   }
 
   /**
@@ -192,8 +192,8 @@ public function testUpdateContribOrder() {
     // its own project on the report.
     $this->assertSession()->responseNotContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
     // The other two should be listed as projects.
-    $this->assertRaw(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString());
-    $this->assertRaw(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString());
 
     // We want to make sure we see the BBB project before the CCC project.
     // Instead of just searching for 'BBB Update test' or something, we want
@@ -400,8 +400,8 @@ public function testUpdateShowDisabledThemes() {
       $this->assertSession()->pageTextNotMatches('/Themes/');
       if ($check_disabled) {
         $this->assertSession()->pageTextContains('Uninstalled themes');
-        $this->assertRaw($base_theme_project_link);
-        $this->assertRaw($sub_theme_project_link);
+        $this->assertSession()->responseContains($base_theme_project_link);
+        $this->assertSession()->responseContains($sub_theme_project_link);
       }
       else {
         $this->assertSession()->pageTextNotContains('Uninstalled themes');
@@ -496,9 +496,9 @@ public function testUpdateBrokenFetchURL() {
     $this->assertSession()->pageTextContainsOnce('Failed to get available update data for one project.');
 
     // The other two should be listed as projects.
-    $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
     $this->assertSession()->responseNotContains(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString());
-    $this->assertRaw(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString());
   }
 
   /**
@@ -543,7 +543,7 @@ public function testHookUpdateStatusAlter() {
     $this->drupalGet('admin/reports/updates');
     $this->assertSession()->responseContains('<h3>Modules</h3>');
     $this->assertSession()->pageTextContains('Security update required!');
-    $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
 
     // Visit the reports page again without the altering and make sure the
     // status is back to normal.
@@ -551,7 +551,7 @@ public function testHookUpdateStatusAlter() {
     $this->drupalGet('admin/reports/updates');
     $this->assertSession()->responseContains('<h3>Modules</h3>');
     $this->assertSession()->pageTextNotContains('Security update required!');
-    $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
 
     // Turn the altering back on and visit the Update manager UI.
     $update_test_config->set('update_status', $update_status)->save();
diff --git a/core/modules/update/tests/src/Functional/UpdateTestBase.php b/core/modules/update/tests/src/Functional/UpdateTestBase.php
index fcffc24cdbc294e37b6947bc86220af386b9ea50..d603aca4f6f8ec77b4090aa8a8ae45aaaadf48d2 100644
--- a/core/modules/update/tests/src/Functional/UpdateTestBase.php
+++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php
@@ -108,7 +108,7 @@ protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
   protected function standardTests() {
     $this->assertSession()->responseContains('<h3>Drupal core</h3>');
     // Verify that the link to the Drupal project appears.
-    $this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
     $this->assertSession()->pageTextNotContains('No available releases found');
     $this->assertSession()->pageTextContains('Last checked:');
   }
diff --git a/core/modules/user/tests/src/Functional/UserAdminTest.php b/core/modules/user/tests/src/Functional/UserAdminTest.php
index 65acd73caa310854a910934bea8212ce795291d5..ae93524c788a81556394eed9f42cbc213bf15b7b 100644
--- a/core/modules/user/tests/src/Functional/UserAdminTest.php
+++ b/core/modules/user/tests/src/Functional/UserAdminTest.php
@@ -76,7 +76,7 @@ public function testUserAdmin() {
 
     // Test for existence of edit link in table.
     $link = $user_a->toLink(t('Edit'), 'edit-form', ['query' => ['destination' => $user_a->toUrl('collection')->toString()]])->toString();
-    $this->assertRaw($link);
+    $this->assertSession()->responseContains($link);
 
     // Test exposed filter elements.
     foreach (['user', 'role', 'permission', 'status'] as $field) {
@@ -185,7 +185,7 @@ public function testNotificationEmailAddress() {
     ]);
     $this->drupalLogin($admin_user);
     $this->drupalGet('admin/config/people/accounts');
-    $this->assertRaw('id="edit-mail-notification-address"');
+    $this->assertSession()->responseContains('id="edit-mail-notification-address"');
     $this->drupalLogout();
 
     // Test custom user registration approval email address(es).
diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
index 85c3e1986bece691b46abd86ee522adad2fcdfa7..515a149f4849ecbb4a3e507852a6978016974481 100644
--- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\user\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Test\AssertMailTrait;
 use Drupal\Core\Url;
@@ -331,10 +330,9 @@ public function testUserPasswordResetLoggedIn() {
     // Log in as a different user.
     $this->drupalLogin($this->account);
     $this->drupalGet($resetURL);
-    $this->assertRaw(new FormattableMarkup(
-      'Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href=":logout">log out</a> and try using the link again.',
-      ['%other_user' => $this->account->getAccountName(), '%resetting_user' => $another_account->getAccountName(), ':logout' => Url::fromRoute('user.logout')->toString()]
-    ));
+    $this->assertSession()->pageTextContains("Another user ({$this->account->getAccountName()}) is already logged into the site on this computer, but you tried to use a one-time link for user {$another_account->getAccountName()}. Please log out and try using the link again.");
+    $this->assertSession()->linkExists('log out');
+    $this->assertSession()->linkByHrefExists(Url::fromRoute('user.logout')->toString());
 
     $another_account->delete();
     $this->drupalGet($resetURL);
diff --git a/core/modules/user/tests/src/Functional/UserPictureTest.php b/core/modules/user/tests/src/Functional/UserPictureTest.php
index cd32b252eb9c857e0e0c80328f6ee72633302851..615359a9f2f573b4b4e20b77a4bb2c83b0a17bfb 100644
--- a/core/modules/user/tests/src/Functional/UserPictureTest.php
+++ b/core/modules/user/tests/src/Functional/UserPictureTest.php
@@ -72,7 +72,7 @@ public function testCreateDeletePicture() {
 
     // Verify that the image is displayed on the user account page.
     $this->drupalGet('user');
-    $this->assertRaw(StreamWrapperManager::getTarget($file->getFileUri()));
+    $this->assertSession()->responseContains(StreamWrapperManager::getTarget($file->getFileUri()));
 
     // Delete the picture.
     $edit = [];
diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php
index 465c74d3a2985015ed18f3322150cb922f62c422..4575ee9ba8e81db4c00aeb4b4d774d99522d0629 100644
--- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php
+++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\user\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Entity\Entity\EntityFormDisplay;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\field\Entity\FieldConfig;
@@ -293,12 +292,12 @@ public function testUniqueFields() {
     $edit = ['mail' => 'test@example.com', 'name' => $account->getAccountName()];
     $this->drupalGet('user/register');
     $this->submitForm($edit, 'Create new account');
-    $this->assertRaw(new FormattableMarkup('The username %value is already taken.', ['%value' => $account->getAccountName()]));
+    $this->assertSession()->pageTextContains("The username {$account->getAccountName()} is already taken.");
 
     $edit = ['mail' => $account->getEmail(), 'name' => $this->randomString()];
     $this->drupalGet('user/register');
     $this->submitForm($edit, 'Create new account');
-    $this->assertRaw(new FormattableMarkup('The email address %value is already taken.', ['%value' => $account->getEmail()]));
+    $this->assertSession()->pageTextContains("The email address {$account->getEmail()} is already taken.");
   }
 
   /**
diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
index 23617e027a11404d313748d5a494f895646a6070..a95f66724da0b27dbd8d98d6747c782f5f536398 100644
--- a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
+++ b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\user\Functional\Views;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\user\Entity\User;
 
 /**
@@ -60,11 +59,7 @@ public function testUserEditAccess() {
     $this->submitForm($edit, 'Apply to selected items');
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [
-      '%action' => 'Block the selected user(s)',
-      '@entity_type_label' => 'User',
-      '%entity_label' => $no_edit_user->label(),
-    ]));
+    $this->assertSession()->pageTextContains("No access to execute Block the selected user(s) on the User {$no_edit_user->label()}.");
 
     // Re-load the account "no_edit" and ensure it is not blocked.
     $no_edit_user = User::load($no_edit_user->id());
diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
index 1ab4de22a8051abd748ae600434bcc9f68c8af4b..74650146e2f790459ff782734a8ebf0b199b489e 100644
--- a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
+++ b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
@@ -83,7 +83,7 @@ public function testBulkForm() {
 
     // Block a user using the bulk form.
     $this->assertTrue($account->isActive(), 'The user is not blocked.');
-    $this->assertRaw($account->label());
+    $this->assertSession()->pageTextContains($account->label());
     $edit = [
       'user_bulk_form[1]' => TRUE,
       'action' => 'user_block_user_action',
diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
index f2e87d53c9e4f24a15f1d51e52f28be48d5cef80..dde9328d752b843b0beea61b7f50ccc20f0b8990 100644
--- a/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
@@ -155,7 +155,7 @@ public function testExposedFilter() {
     $this->drupalGet($path, $options);
     // The actual result should contain all of the user ids.
     foreach ($this->accounts as $account) {
-      $this->assertRaw($account->id());
+      $this->assertSession()->pageTextContains($account->id());
     }
 
     // Pass in an invalid username and a valid username.
@@ -175,7 +175,7 @@ public function testExposedFilter() {
     $this->assertSession()->pageTextNotContains('Unable to find user');
     // The actual result should contain all of the user ids.
     foreach ($this->accounts as $account) {
-      $this->assertRaw($account->id());
+      $this->assertSession()->pageTextContains($account->id());
     }
 
     // Pass in just valid user IDs in the entity_autocomplete target_id format.
@@ -187,7 +187,7 @@ public function testExposedFilter() {
     $this->assertSession()->pageTextNotContains('Unable to find user');
     // The actual result should contain all of the user ids.
     foreach ($this->accounts as $account) {
-      $this->assertRaw($account->id());
+      $this->assertSession()->pageTextContains($account->id());
     }
   }
 
diff --git a/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php b/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
index 494048fd786cd8052c3327293e92c84740437d3d..98c552c7fa553440831dbf55e2549f649e725a7a 100644
--- a/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
@@ -65,11 +65,11 @@ public function testDropbutton() {
 
     // Check if the dropbutton.js library is available.
     $this->drupalGet('admin/content');
-    $this->assertRaw('dropbutton.js');
+    $this->assertSession()->responseContains('dropbutton.js');
     // Check if the dropbutton.js library is available on a cached page to
     // ensure that bubbleable metadata is not lost in the views render workflow.
     $this->drupalGet('admin/content');
-    $this->assertRaw('dropbutton.js');
+    $this->assertSession()->responseContains('dropbutton.js');
   }
 
 }
diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php
index 663df02fbdba765a37ce4a1a2469be354410413f..8eea7fb9faa658b98eaac1fba920db65c4ac4991 100644
--- a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php
@@ -76,7 +76,7 @@ public function testFeedOutput() {
     $this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title'));
     $this->assertEquals($node_link, $this->getSession()->getDriver()->getText('//item/link'));
     // Verify HTML is properly escaped in the description field.
-    $this->assertRaw('&lt;p&gt;A paragraph&lt;/p&gt;');
+    $this->assertSession()->responseContains('&lt;p&gt;A paragraph&lt;/p&gt;');
 
     $view = $this->container->get('entity_type.manager')->getStorage('view')->load('test_display_feed');
     $display = &$view->getDisplay('feed_1');
@@ -137,7 +137,7 @@ public function testFeedFieldOutput() {
     $this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title'));
     $this->assertEquals($node_link, $this->getSession()->getDriver()->getText('//item/link'));
     // Verify HTML is properly escaped in the description field.
-    $this->assertRaw('&lt;p&gt;A paragraph&lt;/p&gt;');
+    $this->assertSession()->responseContains('&lt;p&gt;A paragraph&lt;/p&gt;');
 
     // Change the display to use the nid field, which is rewriting output as
     // 'node/{{ nid }}' and make sure things are still working.
diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
index 9b8a1930b3edebe03f524c2ad15d1abe1051bb8c..92381e1da74c603a83278d1450dcc58fd6064b7c 100644
--- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
@@ -233,7 +233,7 @@ public function testExposedBlock($display) {
 
     // Test that the custom block label is found.
     $this->drupalGet('test_exposed_block');
-    $this->assertRaw('<strong>Custom</strong> titlealert("hacked!");');
+    $this->assertSession()->responseContains('<strong>Custom</strong> titlealert("hacked!");');
 
     // Set label to hidden on the exposed filter form block.
     $block->getPlugin()->setConfigurationValue('label_display', FALSE);
@@ -395,7 +395,7 @@ public function testExposedSortAndItemsPerPage() {
     $escape_1 = Html::escape($expected_label);
     $escape_2 = Html::escape($escape_1);
     // Make sure we see the single-escaped string in the raw output.
-    $this->assertRaw($escape_1);
+    $this->assertSession()->responseContains($escape_1);
     // But no double-escaped string.
     $this->assertSession()->responseNotContains($escape_2);
     // And not the raw label, either.
@@ -448,7 +448,7 @@ public function testFormErrorWithExposedForm() {
     $this->assertNotEmpty($form, 'The exposed form element was found.');
     // Ensure the exposed form is rendered before submitting the normal form.
     $this->assertSession()->responseContains("Apply");
-    $this->assertRaw('<div class="views-row">');
+    $this->assertSession()->responseContains('<div class="views-row">');
 
     $this->submitForm([], 'Submit');
     $this->assertSession()->statusCodeEquals(200);
@@ -456,7 +456,7 @@ public function testFormErrorWithExposedForm() {
     $this->assertNotEmpty($form, 'The exposed form element was found.');
     // Ensure the exposed form is rendered after submitting the normal form.
     $this->assertSession()->responseContains("Apply");
-    $this->assertRaw('<div class="views-row">');
+    $this->assertSession()->responseContains('<div class="views-row">');
   }
 
   /**
diff --git a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
index 50b800a754329d31dfe0b460c7b9a6e6a84f8c17..3392e285353338863c7ef9bdeab42c1a2d94f04e 100644
--- a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
@@ -58,7 +58,7 @@ public function testNumericFormatPlural() {
 
     // Assert that the value is displayed.
     $this->drupalGet('numeric-test');
-    $this->assertRaw('<span class="field-content">0</span>');
+    $this->assertSession()->responseContains('<span class="field-content">0</span>');
 
     // Assert that the user interface has controls to change it.
     $this->drupalGet('admin/structure/views/nojs/handler/numeric_test/page_1/field/count');
@@ -82,7 +82,7 @@ public function testNumericFormatPlural() {
     }
     $this->drupalGet('numeric-test');
     foreach ($numbers as $i => $number) {
-      $this->assertRaw('<span class="field-content">' . $number . ($number == 1 ? ' time' : ' times') . '</span>');
+      $this->assertSession()->responseContains('<span class="field-content">' . $number . ($number == 1 ? ' time' : ' times') . '</span>');
     }
 
     // Add Slovenian and set its plural formula to test multiple plural forms.
@@ -121,12 +121,12 @@ public function testNumericFormatPlural() {
 
     // The view should now use the new plural configuration.
     $this->drupalGet('sl/numeric-test');
-    $this->assertRaw('<span class="field-content">0 time3</span>');
-    $this->assertRaw('<span class="field-content">1 time0</span>');
-    $this->assertRaw('<span class="field-content">2 time1</span>');
-    $this->assertRaw('<span class="field-content">3 time2</span>');
-    $this->assertRaw('<span class="field-content">4 time2</span>');
-    $this->assertRaw('<span class="field-content">42 time3</span>');
+    $this->assertSession()->responseContains('<span class="field-content">0 time3</span>');
+    $this->assertSession()->responseContains('<span class="field-content">1 time0</span>');
+    $this->assertSession()->responseContains('<span class="field-content">2 time1</span>');
+    $this->assertSession()->responseContains('<span class="field-content">3 time2</span>');
+    $this->assertSession()->responseContains('<span class="field-content">4 time2</span>');
+    $this->assertSession()->responseContains('<span class="field-content">42 time3</span>');
 
     // Add an English configuration translation with English plurals.
     $english = \Drupal::languageManager()->getLanguageConfigOverride('en', 'views.view.numeric_test');
@@ -134,12 +134,12 @@ public function testNumericFormatPlural() {
 
     // The view displayed in English should use the English translation.
     $this->drupalGet('numeric-test');
-    $this->assertRaw('<span class="field-content">0 times</span>');
-    $this->assertRaw('<span class="field-content">1 time</span>');
-    $this->assertRaw('<span class="field-content">2 times</span>');
-    $this->assertRaw('<span class="field-content">3 times</span>');
-    $this->assertRaw('<span class="field-content">4 times</span>');
-    $this->assertRaw('<span class="field-content">42 times</span>');
+    $this->assertSession()->responseContains('<span class="field-content">0 times</span>');
+    $this->assertSession()->responseContains('<span class="field-content">1 time</span>');
+    $this->assertSession()->responseContains('<span class="field-content">2 times</span>');
+    $this->assertSession()->responseContains('<span class="field-content">3 times</span>');
+    $this->assertSession()->responseContains('<span class="field-content">4 times</span>');
+    $this->assertSession()->responseContains('<span class="field-content">42 times</span>');
   }
 
   /**
diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
index 71d2b97ba28f33bdcfe982453bd9392697187db5..686e06b68277c811a346a5f81c2d2ada87e8d72a 100644
--- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
@@ -484,7 +484,7 @@ public function testPagerConfigTranslation() {
     ];
     foreach ($labels as $label => $translation) {
       // Check if we can find the translation.
-      $this->assertRaw($translation);
+      $this->assertSession()->pageTextContains($translation);
     }
   }
 
@@ -531,7 +531,7 @@ public function testPagerLocale() {
     $this->drupalGet('nl/test_pager_full', ['query' => ['page' => 1]]);
     foreach ($labels as $label => $translation) {
       // Check if we can find the translation.
-      $this->assertRaw($translation);
+      $this->assertSession()->pageTextContains($translation);
     }
   }
 
diff --git a/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php b/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php
index dcbaf6c165a6d54bd35041f0895a658ba7a4f047..902f985d2ee0ffd05893e435787f0bce5c765c3c 100644
--- a/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php
@@ -60,7 +60,7 @@ public function testSummaryView() {
     $this->drupalGet('test-summary');
 
     // Ensure styles are properly added for summary views.
-    $this->assertRaw('stable/css/views/views.module.css');
+    $this->assertSession()->responseContains('stable/css/views/views.module.css');
 
     $summary_list = $this->cssSelect('ul.views-summary li');
     $this->assertCount(4, $summary_list);
diff --git a/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php b/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php
index a8e0c36ed31dab3fb24be3d58a6b313e27ce8b35..db99f7a6d2752c8c50718a6749ceb29b516abd81 100644
--- a/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php
+++ b/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php
@@ -61,8 +61,8 @@ public function testThemedViewPage() {
     // Make sure a views rendered page is touched.
     $this->drupalGet('test_page_display_200');
 
-    $this->assertRaw("test_basetheme_views_pre_render");
-    $this->assertRaw("test_basetheme_views_post_render");
+    $this->assertSession()->responseContains("test_basetheme_views_pre_render");
+    $this->assertSession()->responseContains("test_basetheme_views_post_render");
 
     // Make sub theme default to test for hook invocation
     // from both sub and base theme.
@@ -74,14 +74,14 @@ public function testThemedViewPage() {
     // Make sure a views rendered page is touched.
     $this->drupalGet('test_page_display_200');
 
-    $this->assertRaw("test_subtheme_views_pre_render");
-    $this->assertRaw("test_subtheme_views_post_render");
+    $this->assertSession()->responseContains("test_subtheme_views_pre_render");
+    $this->assertSession()->responseContains("test_subtheme_views_post_render");
 
-    $this->assertRaw("test_basetheme_views_pre_render");
-    $this->assertRaw("test_basetheme_views_post_render");
+    $this->assertSession()->responseContains("test_basetheme_views_pre_render");
+    $this->assertSession()->responseContains("test_basetheme_views_post_render");
 
     // Verify that the views group title is added.
-    $this->assertRaw('<em class="placeholder">' . count($this->dataSet()) . '</em> items found.');
+    $this->assertSession()->responseContains('<em class="placeholder">' . count($this->dataSet()) . '</em> items found.');
   }
 
 }
diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
index 5e48df6338925facd932e485d9929b7720c45a54..75812cecf54d7afad04faf5418624a1b26e68591 100644
--- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
+++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
@@ -92,9 +92,9 @@ public function testViewsWizardAndListing() {
     $this->assertEquals('2.0', $this->getSession()->getDriver()->getAttribute('//rss', 'version'));
     // The feed should have the same title and nodes as the page.
     $this->assertSession()->responseContains($view2['page[title]']);
-    $this->assertRaw($node1->toUrl('canonical', ['absolute' => TRUE])->toString());
+    $this->assertSession()->responseContains($node1->toUrl('canonical', ['absolute' => TRUE])->toString());
     $this->assertSession()->responseContains($node1->label());
-    $this->assertRaw($node2->toUrl('canonical', ['absolute' => TRUE])->toString());
+    $this->assertSession()->responseContains($node2->toUrl('canonical', ['absolute' => TRUE])->toString());
     $this->assertSession()->responseContains($node2->label());
 
     // Go back to the views page and check if this view is there.
diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
index 1c79b478c218c8646f83dad06f102e914f1a812b..012841d2c1669fc3d69e326684a2b27bd6fd28fc 100644
--- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
@@ -214,7 +214,7 @@ public function testPathDestination() {
     $this->assertSession()->linkByHrefExists('test_page_display_menu/local');
 
     // Check that a dynamic path is shown as text.
-    $this->assertRaw('test_route_with_suffix/%/suffix');
+    $this->assertSession()->responseContains('test_route_with_suffix/%/suffix');
     $this->assertSession()->linkByHrefNotExists(Url::fromUri('base:test_route_with_suffix/%/suffix')->toString());
   }
 
diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
index 478f2a8e00ef5ed78f27ad5d2577ecbaf75b03ff..384e9a5c9a70384d4b27cd817d2818d411e6bd1b 100644
--- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
@@ -89,8 +89,8 @@ public function doPathXssFilterTest() {
     $this->assertSession()->assertEscaped('/<script>alert("hello");</script>');
     $this->assertSession()->assertEscaped('/<script>alert("hello I have placeholders %");</script>');
     // Links should be url-encoded.
-    $this->assertRaw('/%3Cobject%3Emalformed_path%3C/object%3E');
-    $this->assertRaw('/%3Cscript%3Ealert%28%22hello%22%29%3B%3C/script%3E');
+    $this->assertSession()->responseContains('/%3Cobject%3Emalformed_path%3C/object%3E');
+    $this->assertSession()->responseContains('/%3Cscript%3Ealert%28%22hello%22%29%3B%3C/script%3E');
   }
 
   /**
diff --git a/core/modules/views_ui/tests/src/Functional/FilterUITest.php b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
index a6c265bb3153aa89c3a39fae5e8388bbac69be9e..33231e49922ac1d09eaa320efd4adfe7bb06b7f8 100644
--- a/core/modules/views_ui/tests/src/Functional/FilterUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
@@ -90,7 +90,7 @@ public function testFiltersUI() {
     $this->submitForm([], 'Remove group 3');
 
     // Verify that the group 4 is now named as 3.
-    $this->assertRaw('<span>Group 3</span>');
+    $this->assertSession()->responseContains('<span>Group 3</span>');
 
     // Remove the group 3 again.
     $this->submitForm([], 'Remove group 3');
diff --git a/core/modules/views_ui/tests/src/Functional/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
index e9b4458b2be6e5398d46a16b458656166ee58f63..3815a9ec678fdf136d623098cafcecd8f6da9992 100644
--- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php
+++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
@@ -280,7 +280,7 @@ public function testErrorMissingHelp() {
     // description field is shown instead.
     $this->drupalGet('admin/structure/views/nojs/add-handler/test_node_view/default/field');
     $this->assertSession()->pageTextNotContains('Error: missing help');
-    $this->assertRaw('<td class="description"></td>');
+    $this->assertSession()->responseContains('<td class="description"></td>');
 
     // Test that no error message is shown for other fields.
     $this->drupalGet('admin/structure/views/nojs/add-handler/test_view_empty/default/field');
diff --git a/core/modules/views_ui/tests/src/Functional/PreviewTest.php b/core/modules/views_ui/tests/src/Functional/PreviewTest.php
index dc69eed2d5cf5df4c2d0e150599c0be72a807257..8b8add01a9cb118fa7328408f0b105460ba733d6 100644
--- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php
+++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php
@@ -101,7 +101,7 @@ public function testPreviewUI() {
     $this->assertSession()->pageTextContains('Query build time');
     $this->assertSession()->pageTextContains('Query execute time');
     $this->assertSession()->pageTextContains('View render time');
-    $this->assertRaw('<strong>Query</strong>');
+    $this->assertSession()->responseContains('<strong>Query</strong>');
     $query_string = <<<SQL
 SELECT "views_test_data"."name" AS "views_test_data_name"
 FROM
@@ -143,7 +143,7 @@ public function testPreviewAdditionalInfo() {
     $this->assertSession()->elementsCount('xpath', '//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()="Test row count"]', 1);
     // Check that additional assets are attached.
     $this->assertStringContainsString('views_ui_test/views_ui_test.test', $this->getDrupalSettings()['ajaxPageState']['libraries'], 'Attached library found.');
-    $this->assertRaw('css/views_ui_test.test.css');
+    $this->assertSession()->responseContains('css/views_ui_test.test.css');
   }
 
   /**
diff --git a/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php b/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
index 98d0077c51e4589f9d13960884eb20e5c439f428..6b37b8004f4f43df7575abcbb69ffebd78e3cb67 100644
--- a/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
@@ -32,8 +32,8 @@ class ReportFieldsTest extends UITestBase {
    */
   public function testReportFields() {
     $this->drupalGet('admin/reports/fields/views-fields');
-    $this->assertRaw('Used in views');
-    $this->assertRaw('No fields have been used in views yet.');
+    $this->assertSession()->pageTextContains('Used in views');
+    $this->assertSession()->pageTextContains('No fields have been used in views yet.');
 
     // Set up the field_test field.
     $field_storage = FieldStorageConfig::create([
@@ -52,9 +52,9 @@ public function testReportFields() {
 
     // Assert that the newly created field appears in the overview.
     $this->drupalGet('admin/reports/fields/views-fields');
-    $this->assertRaw('<td>field_test</td>');
-    $this->assertRaw('>test_field_field_test</a>');
-    $this->assertRaw('Used in views');
+    $this->assertSession()->responseContains('<td>field_test</td>');
+    $this->assertSession()->responseContains('>test_field_field_test</a>');
+    $this->assertSession()->pageTextContains('Used in views');
   }
 
 }
diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php
index fdc7d5a64f1401f8c28798e5d7d2a859da860e1a..4a8f92ac3332cabdf864b3cc7240bfae6f73f22f 100644
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php
+++ b/core/profiles/standard/tests/src/Functional/StandardTest.php
@@ -83,7 +83,7 @@ public function testStandard() {
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
     // Verify that a line break is present.
-    $this->assertRaw('Then she picked out two somebodies,<br />Sally and me');
+    $this->assertSession()->responseContains('Then she picked out two somebodies,<br />Sally and me');
     $this->submitForm([
       'subject[0][value]' => 'Barfoo',
       'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me',
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
index fe2ece56b179f70658a6828afa00f4ed8a299a00..7e19154118cedff2716f06cc31583cf95b0cae02 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
@@ -86,9 +86,9 @@ protected function setUpLanguage() {
     chmod($filename, 0444);
 
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->pageTextContains($this->info['distribution']['name']);
     // Verify that the requested theme is used.
-    $this->assertRaw($this->info['distribution']['install']['theme']);
+    $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
     // Verify that the "Choose profile" step does not appear.
     $this->assertSession()->pageTextNotContains('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php
index a5388abc08cb29c604df1cdfd7d16988fc255ac9..d8efca525c1f0d5b89917ac8878bfae41a6c247f 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php
@@ -49,11 +49,11 @@ protected function prepareEnvironment() {
    */
   protected function setUpLanguage() {
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->pageTextContains($this->info['distribution']['name']);
     // Verify that the distribution name is used in the site title.
     $this->assertSession()->titleEquals('Choose language | ' . $this->info['distribution']['name']);
     // Verify that the requested theme is used.
-    $this->assertRaw($this->info['distribution']['install']['theme']);
+    $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
     // Verify that the "Choose profile" step does not appear.
     $this->assertSession()->pageTextNotContains('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
index ebc9b62b619d0e2c7d03ab1bcd53be72ca3f6d2a..a83452e3399b002104d9a80afa50d4054f5c118b 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
@@ -97,9 +97,9 @@ protected function setUpSettings() {
     $this->assertEquals('ltr', $direction);
 
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->pageTextContains($this->info['distribution']['name']);
     // Verify that the requested theme is used.
-    $this->assertRaw($this->info['distribution']['install']['theme']);
+    $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
     // Verify that the "Choose profile" step does not appear.
     $this->assertSession()->pageTextNotContains('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
index e43d7b39217606142ae2d829aa2020a6b19d0b3a..90c8c4c62c519f50021b93cbdcbb72d09bea29ab 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
@@ -88,9 +88,9 @@ protected function setUpSettings() {
     $this->assertEquals('ltr', $direction);
 
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->pageTextContains($this->info['distribution']['name']);
     // Verify that the requested theme is used.
-    $this->assertRaw($this->info['distribution']['install']['theme']);
+    $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
     // Verify that the "Choose profile" step does not appear.
     $this->assertSession()->pageTextNotContains('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
index 036196471e11eb43679cb5667a557bd7b6ab4bc0..b47c6d33a20af716a9c91e4c62a4e994c41a788c 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
@@ -49,7 +49,7 @@ protected function setUpSite() {
    * Verifies that the error message in the settings step is correct.
    */
   public function testSetUpSettingsErrorMessage() {
-    $this->assertRaw('<ul><li>Failed to <strong>CREATE</strong> a test table');
+    $this->assertSession()->responseContains('<ul><li>Failed to <strong>CREATE</strong> a test table');
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingInstallationTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingInstallationTest.php
index 1c8bfb9e5cec60b842f1a0d3402f6d240ce24143..663bad70f25faf86463b24fe8bf70ee9bd448193 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingInstallationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingInstallationTest.php
@@ -21,7 +21,7 @@ class InstallerExistingInstallationTest extends InstallerTestBase {
   public function testInstaller() {
     // Verify that Drupal can't be immediately reinstalled.
     $this->visitInstaller();
-    $this->assertRaw('Drupal already installed');
+    $this->assertSession()->pageTextContains('Drupal already installed');
 
     // Delete settings.php and attempt to reinstall again.
     unlink($this->siteDirectory . '/settings.php');
@@ -30,7 +30,7 @@ public function testInstaller() {
     $this->setUpProfile();
     $this->setUpRequirementsProblem();
     $this->setUpSettings();
-    $this->assertRaw('Drupal already installed');
+    $this->assertSession()->pageTextContains('Drupal already installed');
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php
index 73bc4551b38a1954ddad2e741be28790ecd977e5..7e17ec16fb9821ae75e401b423bc2e9af1d51aea 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php
@@ -28,12 +28,12 @@ protected function setUpLanguage() {
     $this->visitInstaller();
     foreach (LanguageManager::getStandardLanguageList() as $langcode => $names) {
       $this->assertSession()->optionExists('edit-langcode', $langcode);
-      $this->assertRaw('>' . $names[1] . '<');
+      $this->assertSession()->responseContains('>' . $names[1] . '<');
     }
 
     // Check that our custom one shows up with the file name indicated language.
     $this->assertSession()->optionExists('edit-langcode', 'xoxo');
-    $this->assertRaw('>xoxo<');
+    $this->assertSession()->responseContains('>xoxo<');
 
     parent::setUpLanguage();
   }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
index 92c402e7c3f3eab2043e4abfaa4f129342363789..4b3f1c605e01f64b37828d09e4280c1c0d74fa60 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
@@ -51,8 +51,8 @@ public function testInstaller() {
   protected function setUpLanguage() {
     // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets and
     // metatags as expected to the first page of the installer.
-    $this->assertRaw("core/themes/seven/css/components/buttons.css");
-    $this->assertRaw('<meta charset="utf-8" />');
+    $this->assertSession()->responseContains("core/themes/seven/css/components/buttons.css");
+    $this->assertSession()->responseContains('<meta charset="utf-8" />');
 
     // Assert that the expected title is present.
     $this->assertEquals('Choose language', $this->cssSelect('main h2')[0]->getText());
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
index a67ac13782c5f500283508a8d2b5ae8df8580c09..b8c6aa378f5fdc035da9d30370d65006af32fb3b 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
@@ -67,8 +67,8 @@ protected function setUpSettings() {
 
     // Ensure that the error message translation is working.
     // cSpell:disable
-    $this->assertRaw('Beheben Sie alle Probleme unten, um die Installation fortzusetzen. Informationen zur Konfiguration der Datenbankserver finden Sie in der <a href="https://www.drupal.org/docs/8/install">Installationshandbuch</a>, oder kontaktieren Sie Ihren Hosting-Anbieter.');
-    $this->assertRaw('<strong>CREATE</strong> ein Test-Tabelle auf Ihrem Datenbankserver mit dem Befehl <em class="placeholder">CREATE TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)</em> fehlgeschlagen.');
+    $this->assertSession()->responseContains('Beheben Sie alle Probleme unten, um die Installation fortzusetzen. Informationen zur Konfiguration der Datenbankserver finden Sie in der <a href="https://www.drupal.org/docs/8/install">Installationshandbuch</a>, oder kontaktieren Sie Ihren Hosting-Anbieter.');
+    $this->assertSession()->responseContains('<strong>CREATE</strong> ein Test-Tabelle auf Ihrem Datenbankserver mit dem Befehl <em class="placeholder">CREATE TABLE {drupal_install_test} (id int NOT NULL PRIMARY KEY)</em> fehlgeschlagen.');
     // cSpell:enable
 
     // Now do it successfully.
@@ -108,7 +108,7 @@ public function testInstaller() {
     $this->drupalGet('admin/config/development/performance');
     $this->submitForm($edit, 'Save configuration');
     $this->drupalGet('<front>');
-    $this->assertRaw('classy/css/components/action-links.css');
+    $this->assertSession()->responseContains('classy/css/components/action-links.css');
 
     // Verify the strings from the translation files were imported.
     $test_samples = ['Save and continue', 'Anonymous'];
diff --git a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
index 1c03b84049261b974854c51521a87673ab92a4c2..ca71d7fb04270d053b65c47edab5563a93be044d 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
@@ -55,9 +55,9 @@ protected function prepareEnvironment() {
    */
   protected function setUpLanguage() {
     // Verify that the distribution name appears.
-    $this->assertRaw('distribution_one');
+    $this->assertSession()->pageTextContains('distribution_one');
     // Verify that the requested theme is used.
-    $this->assertRaw('bartik');
+    $this->assertSession()->responseContains('bartik');
     // Verify that the "Choose profile" step does not appear.
     $this->assertSession()->pageTextNotContains('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php b/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php
index 48cafa3d99c84a374ca429dd907d9ede7b784429..a828dda00f372fb0a38b41f034c9aae301603b77 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php
@@ -38,7 +38,7 @@ protected function installParameters() {
    */
   public function testSiteName() {
     $this->drupalGet('');
-    $this->assertRaw($this->siteName);
+    $this->assertSession()->pageTextContains($this->siteName);
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php
index c6747386f500a7bb2c3828e445fab747a945857e..466c5373592961cd9ad4e702cf7cc1967799f4ef 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php
@@ -19,7 +19,7 @@ class StandardInstallerTest extends ConfigAfterInstallerTestBase {
    */
   public function testInstaller() {
     // Verify that the Standard install profile's default frontpage appears.
-    $this->assertRaw('No front page content has been created yet.');
+    $this->assertSession()->pageTextContains('No front page content has been created yet.');
     // Ensure that the contact link enabled in standard_install() works as
     // expected.
     $this->clickLink('Contact');
@@ -33,7 +33,7 @@ public function testInstaller() {
   protected function setUpSite() {
     // Test that the correct theme is being used.
     $this->assertSession()->responseNotContains('bartik');
-    $this->assertRaw('themes/seven/css/theme/install-page.css');
+    $this->assertSession()->responseContains('themes/seven/css/theme/install-page.css');
     parent::setUpSite();
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
index 73ff4100421e90f4b5b99a46c8ce7a8dcceb5281..05e7a51cbcf19d913cd9ffdbbef078e1214fdf25 100644
--- a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php
@@ -67,6 +67,7 @@ public function testAssertTextHelper() {
    * @covers ::assertRaw
    */
   public function testAssertRaw() {
+    $this->expectDeprecation('AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738');
     $this->expectDeprecation('Calling AssertLegacyTrait::assertRaw() with more that one argument is deprecated in drupal:8.2.0 and the method is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738');
     $this->page->getText()->willReturn('foo bar bar');
     $this->assertRaw('foo', '\'foo\' should be present.');
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
index aec1092b5703f9e4ced47c7de69629c18f75fba3..c688d46a421efa39f778df9364f5e183338f35f4 100644
--- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -119,8 +119,6 @@ public static function getSkippedDeprecations() {
       "The \"Drupal\Tests\Listeners\DrupalListener\" class implements \"PHPUnit\Framework\TestListener\" that is deprecated Use the `TestHook` interfaces instead.",
       "The \"Drupal\Tests\Listeners\DrupalListener\" class uses \"PHPUnit\Framework\TestListenerDefaultImplementation\" that is deprecated The `TestListener` interface is deprecated.",
       "The \"PHPUnit\Framework\TestSuite\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\TestSuites\TestSuiteBase\".",
-      // Simpletest's legacy assertion methods.
-      'AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738',
       // PHPUnit 9.
       "The \"PHPUnit\TextUI\DefaultResultPrinter\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\Listeners\HtmlOutputPrinter\".",
     ];