diff --git a/core/modules/action/tests/src/Functional/ActionListTest.php b/core/modules/action/tests/src/Functional/ActionListTest.php
index 7cb3def4a7..667b255b6e 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()->responseContains('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 4b393c2817..0ce604231c 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/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php
index 2a4a7452e2..550e338752 100644
--- a/core/modules/action/tests/src/Functional/ConfigurationTest.php
+++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php
@@ -83,7 +83,7 @@ public function testActionConfiguration() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Make sure that the action was actually deleted.
-    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
+    $this->assertSession()->responseContains(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
     $this->drupalGet('admin/config/system/actions');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
index ed1ce4fd67..7b82d49406 100644
--- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
@@ -37,7 +37,7 @@ public function testAddFeed() {
     $this->drupalGet('aggregator/sources/' . $feed->id());
     $this->assertSession()->statusCodeEquals(200);
     $this->assertText($feed->label(), 'Page title');
-    $this->assertRaw($feed->getWebsiteUrl());
+    $this->assertSession()->responseContains($feed->getWebsiteUrl());
 
     // Try to add a duplicate.
     $edit = [
@@ -46,8 +46,8 @@ public function testAddFeed() {
       'refresh' => '900',
     ];
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
-    $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
-    $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
+    $this->assertSession()->responseContains(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
+    $this->assertSession()->responseContains(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
 
     // Delete feed.
     $this->deleteFeed($feed);
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
index 54b57137ad..8efc0b8865 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
@@ -89,7 +89,7 @@ public function createFeed($feed_url = NULL, array $edit = []) {
    */
   public function deleteFeed(FeedInterface $feed) {
     $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
-    $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
+    $this->assertSession()->responseContains(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
   }
 
   /**
@@ -212,7 +212,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
    */
   public function deleteFeedItems(FeedInterface $feed) {
     $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
-    $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
+    $this->assertSession()->responseContains(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
   }
 
   /**
diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
index 95be9e5171..3ca57d645b 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->assertText('First example feed item title');
     $this->assertLinkByHref('http://example.com/example-turns-one');
     $this->assertText('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()->responseContains("Second example feed item title.");
     $this->assertText('Long link feed item title');
     $this->assertText('Long link feed item description');
     $this->assertLinkByHref('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');
@@ -85,7 +85,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;");
   }
 
   /**
@@ -113,7 +113,7 @@ public function testInvalidFeed() {
     // Update the feed. Use the UI to be able to check the message easily.
     $this->drupalGet('admin/config/services/aggregator');
     $this->clickLink(t('Update items'));
-    $this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
+    $this->assertSession()->responseContains(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
   }
 
 }
diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
index ece1634c0d..f0bc5f41a8 100644
--- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
@@ -56,7 +56,7 @@ public function validateImportFormFields() {
 
     $edit = [];
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
-    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
+    $this->assertSession()->responseContains(t('<em>Either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
 
     $path = $this->getEmptyOpml();
     $edit = [
@@ -64,7 +64,7 @@ public function validateImportFormFields() {
       'remote' => file_create_url($path),
     ];
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
-    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
+    $this->assertSession()->responseContains(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
 
     $edit = ['remote' => 'invalidUrl://empty'];
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
@@ -104,8 +104,8 @@ protected function submitImportForm() {
       'refresh'       => '900',
     ];
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
-    $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified');
-    $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified');
+    $this->assertSession()->responseContains(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified');
+    $this->assertSession()->responseContains(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified');
 
     $after = $count_query->execute();
     $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
index 0647b16cb2..2b265fbf01 100644
--- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
+++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
@@ -41,7 +41,7 @@ public function testIPAddressValidation() {
     $this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
     $ip = $connection->query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $edit['ip']])->fetchField();
     $this->assertNotEmpty($ip, 'IP address found in database.');
-    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.');
+    $this->assertSession()->responseContains(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.');
 
     // Try to block an IP address that's already blocked.
     $edit = [];
@@ -72,7 +72,7 @@ public function testIPAddressValidation() {
     $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add'));
     $ip = $connection->query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $submit_ip])->fetchField();
     $this->assertNotEmpty($ip, 'IP address found in database');
-    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.');
+    $this->assertSession()->responseContains(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.');
 
     // Submit your own IP address. This fails, although it works when testing
     // manually.
diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
index 96b52757ea..445037d525 100644
--- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
+++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
@@ -250,17 +250,17 @@ public function testControllerNotCalledBeforeAuth() {
     $this->assertSession()->statusCodeEquals(401);
     $this->drupalGet('/basic_auth_test/state/read');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('nope');
+    $this->assertSession()->responseContains('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()->responseContains('Done');
 
     $this->mink->resetSessions();
     $this->drupalGet('/basic_auth_test/state/read');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('yep');
+    $this->assertSession()->responseContains('yep');
   }
 
 }
diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index acafd7d9aa..be2b251c9d 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -94,12 +94,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=' . base_path() . 'user/1" />' . "\n" . '</noscript>');
+    $this->assertSession()->responseContains('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/1" />' . "\n" . '</noscript>');
     $this->assertNoRaw($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
     $this->assertBigPipeNoJsCookieExists(TRUE);
     $this->assertNoRaw('<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.
@@ -110,12 +110,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->assertNoRaw($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
     $this->assertBigPipeNoJsCookieExists(TRUE);
     $this->assertNoRaw('<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();
@@ -184,7 +184,7 @@ public function testBigPipe() {
       1 => $cases['html']->bigPipePlaceholderId,
     ]);
 
-    $this->assertRaw('</body>', 'Closing body tag present.');
+    $this->assertSession()->responseContains('</body>', 'Closing body tag present.');
 
     $this->pass('Verifying BigPipe assets are present…', 'Debug');
     $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
@@ -207,8 +207,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()->responseContains('The website encountered an unexpected error. Please try again later');
+    $this->assertSession()->responseContains('You are not allowed to say llamas are not cool!');
     $this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent: error occurred before then.');
     $this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
     // The exception is expected. Do not interpret it as a test failure.
@@ -265,7 +265,7 @@ public function testBigPipeNoJs() {
 
     $this->pass('Verifying BigPipe assets are absent…', 'Debug');
     $this->assertTrue(!isset($this->getDrupalSettings()['bigPipePlaceholderIds']) && empty($this->getDrupalSettings()['ajaxPageState']), 'BigPipe drupalSettings and BigPipe asset library absent.');
-    $this->assertRaw('</body>', 'Closing body tag present.');
+    $this->assertSession()->responseContains('</body>', 'Closing body tag present.');
 
     // Verify that 4xx responses work fine. (4xx responses are handled by
     // subrequests to a route pointing to a controller with the desired output.)
@@ -276,8 +276,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()->responseContains('The website encountered an unexpected error. Please try again later');
+    $this->assertSession()->responseContains('You are not allowed to say llamas are not cool!');
     $this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
     // The exception is expected. Do not interpret it as a test failure.
     unlink($this->root . '/' . $this->siteDirectory . '/error.log');
@@ -300,7 +300,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()->responseContains('The count is 1.');
     $this->assertNoRaw('The count is 2.');
     $this->assertNoRaw('The count is 3.');
     $raw_content = $this->getSession()->getPage()->getContent();
@@ -314,7 +314,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()->responseContains('The count is 1.');
     $this->assertNoRaw('The count is 2.');
     $this->assertNoRaw('The count is 3.');
   }
@@ -341,7 +341,7 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
       $this->pass('Checking whether the replacement for the BigPipe no-JS placeholder "' . $big_pipe_nojs_placeholder . '" is present:');
       $this->assertNoRaw($big_pipe_nojs_placeholder);
       if ($expected_replacement !== NULL) {
-        $this->assertRaw($expected_replacement);
+        $this->assertSession()->responseContains($expected_replacement);
       }
     }
   }
@@ -364,7 +364,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
       $this->pass('BigPipe placeholder: ' . $big_pipe_placeholder_id, 'Debug');
       // Verify expected placeholder.
       $expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
-      $this->assertRaw($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
+      $this->assertSession()->responseContains($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
       $pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_html);
       $placeholder_positions[$pos] = $big_pipe_placeholder_id;
       // Verify expected placeholder replacement.
@@ -376,7 +376,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
         continue;
       }
       $this->assertEqual($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;
     }
@@ -395,8 +395,8 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
     $this->assertEqual(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()));
 
     $this->pass('Verifying BigPipe start/stop signals…', 'Debug');
-    $this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
-    $this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
+    $this->assertSession()->responseContains(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
+    $this->assertSession()->responseContains(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
     $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/BlockInvalidRegionTest.php b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
index 0389375b8c..314a79be54 100644
--- a/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
+++ b/core/modules/block/tests/src/Functional/BlockInvalidRegionTest.php
@@ -49,7 +49,7 @@ public function testBlockInInvalidRegion() {
 
     // Clearing the cache should disable the test block placed in the invalid region.
     $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
-    $this->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.');
+    $this->assertSession()->responseContains($warning_message, 'Enabled block was in the invalid region and has been disabled.');
 
     // Clear the cache to check if the warning message is not triggered.
     $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches');
diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php
index 8e4a0287bc..72965a87fb 100644
--- a/core/modules/block/tests/src/Functional/BlockTest.php
+++ b/core/modules/block/tests/src/Functional/BlockTest.php
@@ -229,17 +229,17 @@ public function testBlock() {
     // Test deleting the block from the edit form.
     $this->drupalGet('admin/structure/block/manage/' . $block['id']);
     $this->clickLink(t('Remove block'));
-    $this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block['settings[label]']]));
+    $this->assertSession()->responseContains(t('Are you sure you want to remove the block @name?', ['@name' => $block['settings[label]']]));
     $this->drupalPostForm(NULL, [], t('Remove'));
-    $this->assertRaw(t('The block %name has been removed.', ['%name' => $block['settings[label]']]));
+    $this->assertSession()->responseContains(t('The block %name has been removed.', ['%name' => $block['settings[label]']]));
 
     // Test deleting a block via "Configure block" link.
     $block = $this->drupalPlaceBlock('system_powered_by_block');
     $this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]);
     $this->clickLink(t('Remove block'));
-    $this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block->label()]));
+    $this->assertSession()->responseContains(t('Are you sure you want to remove the block @name?', ['@name' => $block->label()]));
     $this->drupalPostForm(NULL, [], t('Remove'));
-    $this->assertRaw(t('The block %name has been removed.', ['%name' => $block->label()]));
+    $this->assertSession()->responseContains(t('The block %name has been removed.', ['%name' => $block->label()]));
     $this->assertUrl('admin');
     $this->assertNoRaw($block->id());
   }
diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php
index 86489ada21..08ea357371 100644
--- a/core/modules/block/tests/src/Functional/BlockUiTest.php
+++ b/core/modules/block/tests/src/Functional/BlockUiTest.php
@@ -254,7 +254,7 @@ public function testContextAwareBlocks() {
     $this->drupalGet('');
     $this->assertText('Test context-aware block');
     $this->assertText('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 a4c27db7e6..c930078e9f 100644
--- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
+++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
@@ -378,8 +378,8 @@ public function testBlockContextualLinks() {
     $cached_id = 'block:block=' . $cached_block->id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en';
     $cached_id_token = Crypt::hmacBase64($cached_id, Settings::getHashSalt() . $this->container->get('private_key')->get());
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
-    $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token]) . '></div>', new FormattableMarkup('Contextual link placeholder with id @id exists.', ['@id' => $id]));
-    $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token]) . '></div>', new FormattableMarkup('Contextual link placeholder with id @id exists.', ['@id' => $cached_id]));
+    $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token]) . '></div>', new FormattableMarkup('Contextual link placeholder with id @id exists.', ['@id' => $id]));
+    $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token]) . '></div>', new FormattableMarkup('Contextual link placeholder with id @id exists.', ['@id' => $cached_id]));
 
     // Get server-rendered contextual links.
     // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
index 49d72b8f16..17154895f9 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -59,7 +59,7 @@ public function testBlockContentCreation() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('@block %name has been created.', [
       '@block' => 'basic',
       '%name' => $edit['info[0][value]'],
     ]), 'Basic block created.');
@@ -79,7 +79,7 @@ public function testBlockContentCreation() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('A custom block with block description %value already exists.', [
       '%value' => $edit['info[0][value]'],
     ]));
     $this->assertSession()->statusCodeEquals(200);
@@ -97,7 +97,7 @@ public function testBlockContentCreationMultipleViewModes() {
       'label' => 'Test View Mode',
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Saved the %label view mode.', ['%label' => $edit['label']]));
 
     $this->drupalLogin($this->adminUser);
 
@@ -108,7 +108,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('@block %name has been created.', [
       '@block' => 'basic',
       '%name' => $edit['info[0][value]'],
     ]), 'Basic block created.');
@@ -163,7 +163,7 @@ public function testBlockContentCreationMultipleViewModes() {
     $this->drupalPostForm('block/add/basic', $edit, t('Save'));
 
     // Check that the Basic block has been created.
-    $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('A custom block with block description %value already exists.', [
       '%value' => $edit['info[0][value]'],
     ]));
     $this->assertSession()->statusCodeEquals(200);
@@ -183,7 +183,7 @@ public function testDefaultBlockContentCreation() {
     $this->drupalPostForm('block/add', $edit, t('Save'));
 
     // Check that the block has been created and that it is a basic block.
-    $this->assertRaw(new FormattableMarkup('@block %name has been created.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('@block %name has been created.', [
       '@block' => 'basic',
       '%name' => $edit['info[0][value]'],
     ]), 'Basic block created.');
@@ -255,7 +255,7 @@ public function testBlockDelete() {
     $this->assertText(\Drupal::translation()->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.'));
 
     $this->drupalPostForm(NULL, [], 'Delete');
-    $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']]));
+    $this->assertSession()->responseContains(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']]));
 
     // Create another block and force the plugin cache to flush.
     $edit2 = [];
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
index b2111370b6..7ece26b642 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php
@@ -34,7 +34,7 @@ public function testPageEdit() {
     // Ensure user was able to view the block.
     $this->assertSession()->statusCodeEquals(200);
     $this->drupalGet('<front>');
-    $this->assertRaw(t('This block is broken or missing. You may be missing content or you might need to enable the original module.'));
+    $this->assertSession()->responseContains(t('This block is broken or missing. You may be missing content or you might need to enable the original module.'));
   }
 
 }
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
index 1f4693d4be..bc1b134bf2 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
@@ -153,7 +153,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
index 1485c63791..eaec40060d 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
@@ -112,7 +112,7 @@ public function testBlockContentTypeEditing() {
 
     // Verify that title and body fields are displayed.
     $this->drupalGet('block/add/basic');
-    $this->assertRaw('Block description', 'Block info field was found.');
+    $this->assertSession()->responseContains('Block description', 'Block info field was found.');
     $this->assertNotEmpty($this->cssSelect('#edit-body-0-value'), 'Body field was found.');
 
     // Change the block type name.
@@ -132,7 +132,7 @@ public function testBlockContentTypeEditing() {
     \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
 
     $this->drupalGet('block/add');
-    $this->assertRaw('Bar', 'New name was displayed.');
+    $this->assertSession()->responseContains('Bar', 'New name was displayed.');
     $this->clickLink('Bar');
     $this->assertUrl(Url::fromRoute('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE])->toString(), [], 'Original machine name was used in URL.');
 
@@ -161,7 +161,7 @@ public function testBlockContentTypeDeletion() {
     $block = $this->createBlockContent(FALSE, 'foo');
     // Attempt to delete the block type, which should not be allowed.
     $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()]),
       'The block type will not be deleted until all blocks of that type are removed.'
     );
@@ -171,7 +171,7 @@ public function testBlockContentTypeDeletion() {
     $block->delete();
     // Attempt to delete the block type, which should now be allowed.
     $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()]),
       'The block type is available for deletion.'
     );
diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php
index 2bb112b2a8..719dbaa0a2 100644
--- a/core/modules/book/tests/src/Functional/BookTest.php
+++ b/core/modules/book/tests/src/Functional/BookTest.php
@@ -93,23 +93,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');
   }
 
   /**
@@ -209,7 +209,7 @@ public function testBookExport() {
     // Make sure each part of the book is there.
     foreach ($nodes as $node) {
       $this->assertText($node->label(), 'Node title found in printer friendly version.');
-      $this->assertRaw($node->body->processed, 'Node body found in printer friendly version.');
+      $this->assertSession()->responseContains($node->body->processed, 'Node body found in printer friendly version.');
     }
 
     // Make sure we can't export an unsupported format.
@@ -382,7 +382,7 @@ public function testBookDelete() {
     $nodes = $this->createBook();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet($this->book->toUrl('delete-form'));
-    $this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
+    $this->assertSession()->responseContains(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
     // Delete parent, and visit a child page.
     $this->drupalPostForm($this->book->toUrl('delete-form'), [], t('Delete'));
     $this->drupalGet($nodes[0]->toUrl());
@@ -411,7 +411,7 @@ public function testBookOutline() {
 
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/' . $empty_book->id() . '/outline');
-    $this->assertRaw(t('Book outline'));
+    $this->assertSession()->responseContains(t('Book outline'));
     $this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
     $this->assertNoLink(t('Remove from book outline'));
 
@@ -432,9 +432,9 @@ public function testBookOutline() {
 
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/' . $book->id() . '/outline');
-    $this->assertRaw(t('Book outline'));
+    $this->assertSession()->responseContains(t('Book outline'));
     $this->clickLink(t('Remove from book outline'));
-    $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
+    $this->assertSession()->responseContains(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
 
     // Create a new node and set the book after the node was created.
     $node = $this->drupalCreateNode(['type' => 'book']);
diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php
index c03dc6c571..0dc12f06a5 100644
--- a/core/modules/book/tests/src/Functional/BookTestTrait.php
+++ b/core/modules/book/tests/src/Functional/BookTestTrait.php
@@ -107,14 +107,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(), 'Previous page link found.');
+      $this->assertSession()->responseContains(Link::fromTextAndUrl($text, $url)->toString(), 'Previous page link found.');
     }
 
     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(), 'Up page link found.');
+      $this->assertSession()->responseContains(Link::fromTextAndUrl('Up', $url)->toString(), 'Up page link found.');
     }
 
     if ($next) {
@@ -122,7 +122,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(), 'Next page link found.');
+      $this->assertSession()->responseContains(Link::fromTextAndUrl($text, $url)->toString(), 'Next page link found.');
     }
 
     // Compute the expected breadcrumb.
@@ -145,7 +145,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
     // Check printer friendly version.
     $this->drupalGet('book/export/html/' . $node->id());
     $this->assertText($node->label(), 'Printer friendly title found.');
-    $this->assertRaw($node->body->processed, 'Printer friendly body found.');
+    $this->assertSession()->responseContains($node->body->processed, 'Printer friendly body found.');
 
     $number++;
   }
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
index ac551ec121..3da327fb69 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php
@@ -79,7 +79,7 @@ public function testExistingFormat() {
       'editor[editor]' => 'ckeditor',
     ];
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
-    $this->assertRaw(t('You must configure the selected text editor.'));
+    $this->assertSession()->responseContains(t('You must configure the selected text editor.'));
 
     // Ensure the CKEditor editor returns the expected default settings.
     $expected_default_settings = [
@@ -188,13 +188,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/CKEditorStylesComboAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
index d2d1186ffc..7d5032491a 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorStylesComboAdminTest.php
@@ -95,7 +95,7 @@ public function testExistingFormat() {
       'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Title\n\n",
     ];
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
-    $this->assertRaw(t('Each style must have a unique label.'));
+    $this->assertSession()->responseContains(t('Each style must have a unique label.'));
     $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n";
     $editor = Editor::load($this->format);
     $this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
index 1ce136a905..fa0915b4bb 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorToolbarButtonTest.php
@@ -75,7 +75,7 @@ public function testImageButtonDisplay() {
       return trim(Json::encode($html), '"');
     };
     $markup = $json_encode(file_url_transform_relative(file_create_url('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 5802e58ca7..d282c655c9 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->assertText('TEST COLOR PREVIEW');
 
     $this->assertNoRaw('<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 015d720294..581ed9497b 100644
--- a/core/modules/color/tests/src/Functional/ColorTest.php
+++ b/core/modules/color/tests/src/Functional/ColorTest.php
@@ -208,7 +208,7 @@ public function testOverrideAndResetScheme() {
 
     $this->drupalGet('');
     $this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
-    $this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
+    $this->assertSession()->responseContains('bartik/logo.svg', 'Make sure the original bartik logo exists.');
 
     // Log in and set the color scheme to 'slate'.
     $this->drupalLogin($this->bigUser);
@@ -218,7 +218,7 @@ public function testOverrideAndResetScheme() {
     // Visit the homepage and ensure color changes.
     $this->drupalLogout();
     $this->drupalGet('');
-    $this->assertRaw('files/color/bartik-', 'Make sure the color logo is being used.');
+    $this->assertSession()->responseContains('files/color/bartik-', 'Make sure the color logo is being used.');
     $this->assertNoRaw('bartik/logo.svg', 'Make sure the original bartik logo does not exist.');
 
     // Log in and set the color scheme back to default (delete config).
@@ -230,7 +230,7 @@ public function testOverrideAndResetScheme() {
     $this->drupalLogout();
     $this->drupalGet('');
     $this->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
-    $this->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
+    $this->assertSession()->responseContains('bartik/logo.svg', 'Make sure the original bartik logo exists.');
   }
 
 }
diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
index 22c1fa748f..8e416c56c8 100644
--- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
@@ -277,8 +277,8 @@ public function testCommentedTranslationDeletion() {
       "comments[{$comment2->id()}]" => 1,
     ];
     $this->drupalPostForm('admin/content/comment', $edit, t('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->assertText('English');
     $this->assertText('Urdu');
     $this->drupalPostForm(NULL, [], t('Delete'));
diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
index cc6c466252..0ab7b78b0a 100644
--- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
@@ -77,7 +77,7 @@ public function testAnonymous() {
       'comment_body[0][value]' => $this->randomMachineName(),
     ];
     $this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save'));
-    $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
+    $this->assertSession()->responseContains(t('The name you used (%name) belongs to a registered user.', [
       '%name' => $this->adminUser->getAccountName(),
     ]));
 
@@ -110,7 +110,7 @@ public function testAnonymous() {
       'comment_body[0][value]' => $this->randomMachineName(),
     ];
     $this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save'));
-    $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
+    $this->assertSession()->responseContains(t('The name you used (%name) belongs to a registered user.', [
       '%name' => $this->adminUser->getAccountName(),
     ]));
 
@@ -137,21 +137,21 @@ 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, "The anonymous user's name is correct when editing the comment.");
+    $this->assertSession()->responseContains($author_name, "The anonymous user's name is correct when editing the comment.");
     $this->assertFieldByName('uid', '', 'The author field is empty (i.e. anonymous) when editing the comment.');
-    $this->assertRaw($author_mail, "The anonymous user's email address is correct when editing the comment.");
+    $this->assertSession()->responseContains($author_mail, "The anonymous user's email address is correct when editing the comment.");
 
     // Unpublish comment.
     $this->performCommentOperation($anonymous_comment3, 'unpublish');
 
     $this->drupalGet('admin/content/comment/approval');
-    $this->assertRaw('comments[' . $anonymous_comment3->id() . ']', 'Comment was unpublished.');
+    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']', 'Comment was unpublished.');
 
     // Publish comment.
     $this->performCommentOperation($anonymous_comment3, 'publish', TRUE);
 
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $anonymous_comment3->id() . ']', 'Comment was published.');
+    $this->assertSession()->responseContains('comments[' . $anonymous_comment3->id() . ']', 'Comment was published.');
 
     // 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 2a3ff3e6a8..68567a277b 100644
--- a/core/modules/comment/tests/src/Functional/CommentBlockTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
@@ -88,7 +88,7 @@ public function testRecentCommentBlock() {
     for ($i = 0; $i < 10; $i++) {
       $this->clickLink($comments[$i]->getSubject());
       $this->assertText($comments[$i]->getSubject(), 'Comment link goes to correct page.');
-      $this->assertRaw('<link rel="canonical"', 'Canonical URL was found in the HTML head');
+      $this->assertSession()->responseContains('<link rel="canonical"', 'Canonical URL was found in the HTML head');
     }
   }
 
diff --git a/core/modules/comment/tests/src/Functional/CommentCSSTest.php b/core/modules/comment/tests/src/Functional/CommentCSSTest.php
index a4a929132c..1334852780 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(drupal_get_path('module', 'comment') . '/js/comment-by-viewer.js', 'drupal.comment-by-viewer library is present.');
+        $this->assertSession()->responseContains(drupal_get_path('module', 'comment') . '/js/comment-by-viewer.js', 'drupal.comment-by-viewer library is present.');
       }
 
       // 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 6018b9d730..153504d285 100644
--- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php
@@ -311,7 +311,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 2d090826bc..c91eba2707 100644
--- a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
@@ -139,7 +139,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 d6233ca35e..727851d36d 100644
--- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php
@@ -238,7 +238,7 @@ public function performCommentOperation($comment, $operation, $approval = FALSE)
 
     if ($operation == 'delete') {
       $this->drupalPostForm(NULL, [], t('Delete'));
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
+      $this->assertSession()->responseContains(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
     }
     else {
       $this->assertText(t('The update has been performed.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
@@ -313,12 +313,12 @@ public function testCommentFunctionality() {
     // Unpublish the comment.
     $this->performCommentOperation($comment1, 'unpublish');
     $this->drupalGet('admin/content/comment/approval');
-    $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was unpublished.');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']', 'Comment was unpublished.');
 
     // Publish the comment.
     $this->performCommentOperation($comment1, 'publish', TRUE);
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was published.');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']', 'Comment was published.');
 
     // Delete the comment.
     $this->performCommentOperation($comment1, 'delete');
@@ -331,7 +331,7 @@ public function testCommentFunctionality() {
 
     // Check that the comment was found.
     $this->drupalGet('admin/content/comment');
-    $this->assertRaw('comments[' . $comment1->id() . ']', 'Comment was published.');
+    $this->assertSession()->responseContains('comments[' . $comment1->id() . ']', 'Comment was published.');
 
     // Check that entity access applies to administrative page.
     $this->assertText($this->entity->label(), 'Name of commented account found.');
diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
index 25da658ad6..710d99b2d3 100644
--- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php
@@ -45,7 +45,7 @@ public function testCommentPaging() {
     // Check the first page of the node, and confirm the correct comments are
     // shown.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw(t('next'), 'Paging links found.');
+    $this->assertSession()->responseContains(t('next'), 'Paging links found.');
     $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page 1.');
     $this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 1.');
     $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.');
@@ -380,26 +380,26 @@ public function testTwoPagers() {
     // Check the first page of the node, and confirm the correct comments are
     // shown.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw(t('next'), 'Paging links found.');
-    $this->assertRaw('Comment 1 on field comment');
-    $this->assertRaw('Comment 1 on field comment_2');
+    $this->assertSession()->responseContains(t('next'), 'Paging links found.');
+    $this->assertSession()->responseContains('Comment 1 on field comment');
+    $this->assertSession()->responseContains('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()->responseContains('Comment 2 on field comment');
+    $this->assertSession()->responseContains('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()->responseContains('Comment 1 on field comment');
+    $this->assertSession()->responseContains('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()->responseContains('Comment 2 on field comment');
+    $this->assertSession()->responseContains('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 9217d3dceb..b8aeb28588 100644
--- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php
@@ -56,7 +56,7 @@ public function testCommentPreview() {
     $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview'));
     $this->assertInstanceOf(MarkupInterface::class, $this->webUser->getDisplayName());
     $this->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 b05bfc2c7d..02fe9456d2 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, 'Comments as part of RSS feed.');
+    $this->assertSession()->responseContains($raw, 'Comments as part of RSS feed.');
 
     // Hide comments from RSS feed and check presence.
     $this->node->set('comment', CommentItemInterface::HIDDEN);
diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php
index abdae813e0..694e74a90d 100644
--- a/core/modules/comment/tests/src/Functional/CommentTestBase.php
+++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php
@@ -364,7 +364,7 @@ public function performCommentOperation(CommentInterface $comment, $operation, $
 
     if ($operation == 'delete') {
       $this->drupalPostForm(NULL, [], t('Delete'));
-      $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
+      $this->assertSession()->responseContains(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
     }
     else {
       $this->assertText(t('The update has been performed.'), new FormattableMarkup('Operation "@operation" was performed on comment.', ['@operation' => $operation]));
diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
index 9977208037..0be5247394 100644
--- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
@@ -233,7 +233,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
index d13b9c6296..ae42c6894b 100644
--- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php
@@ -112,7 +112,7 @@ public function testCommentTypeEditing() {
     $this->drupalPostForm('admin/structure/comment/manage/comment', $edit, t('Save'));
 
     $this->drupalGet('admin/structure/comment');
-    $this->assertRaw('Bar', 'New name was displayed.');
+    $this->assertSession()->responseContains('Bar', 'New name was displayed.');
     $this->clickLink('Manage fields');
     $this->assertUrl(Url::fromRoute('entity.comment.field_ui_fields', ['comment_type' => 'comment'], ['absolute' => TRUE])->toString(), [], 'Original machine name was used in URL.');
     $this->assertCount(1, $this->cssSelect('tr#comment-body'), 'Body field exists.');
@@ -156,11 +156,11 @@ public function testCommentTypeDeletion() {
 
     // Attempt to delete the comment type, which should not be allowed.
     $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', ['%label' => $type->label()]),
       'The comment type will not be deleted until all comments of that type are removed.'
     );
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
         '%label' => 'foo',
         '%field' => 'node.foo',
@@ -174,7 +174,7 @@ public function testCommentTypeDeletion() {
     $field_storage->delete();
     // Attempt to delete the comment type, which should now be allowed.
     $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()]),
       'The comment type is available for deletion.'
     );
@@ -192,7 +192,7 @@ public function testCommentTypeDeletion() {
     // Delete the comment type.
     $this->drupalPostForm('admin/structure/comment/manage/' . $type->id() . '/delete', [], t('Delete'));
     $this->assertNull(CommentType::load($type->id()), 'Comment type deleted.');
-    $this->assertRaw(t('The comment type %label has been deleted.', ['%label' => $type->label()]));
+    $this->assertSession()->responseContains(t('The comment type %label has been deleted.', ['%label' => $type->label()]));
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
index ed92b1b69d..d1eb42853b 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
@@ -272,14 +272,14 @@ public function testPager() {
     $this->drupalGet('admin/structure/config_test');
 
     // Item 51 should not be present.
-    $this->assertRaw('Test config entity 50', 'Config entity 50 is shown.');
+    $this->assertSession()->responseContains('Test config entity 50', 'Config entity 50 is shown.');
     $this->assertNoRaw('Test config entity 51', 'Config entity 51 is on the next page.');
 
     // Browse to the next page.
     $this->clickLink(t('Page 2'));
     $this->assertNoRaw('Test config entity 50', 'Test config entity 50 is on the previous page.');
-    $this->assertRaw('dotted.default', 'Default config entity appears on page 2.');
-    $this->assertRaw('Test config entity 51', 'Test config entity 51 is on page 2.');
+    $this->assertSession()->responseContains('dotted.default', 'Default config entity appears on page 2.');
+    $this->assertSession()->responseContains('Test config entity 51', 'Test config entity 51 is on page 2.');
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
index 30dd0cf231..e11996ed26 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
@@ -254,7 +254,7 @@ public function testCRUDUI() {
     $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
     $this->assertUrl('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw($message_insert);
+    $this->assertSession()->responseContains($message_insert);
     $this->assertNoRaw($message_update);
     $this->assertLinkByHref("admin/structure/config_test/manage/$id");
 
@@ -266,7 +266,7 @@ public function testCRUDUI() {
     $this->assertUrl('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw($message_insert);
-    $this->assertRaw($message_update);
+    $this->assertSession()->responseContains($message_update);
     $this->assertLinkByHref("admin/structure/config_test/manage/$id");
     $this->assertLinkByHref("admin/structure/config_test/manage/$id/delete");
 
@@ -278,7 +278,7 @@ public function testCRUDUI() {
     $this->assertUrl('admin/structure/config_test');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw($message_update);
-    $this->assertRaw($message_delete);
+    $this->assertSession()->responseContains($message_delete);
     $this->assertNoText($label1);
     $this->assertNoLinkByHref("admin/structure/config_test/manage/$id");
 
@@ -316,7 +316,7 @@ public function testCRUDUI() {
     $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
     $this->assertSession()->statusCodeEquals(200);
     $message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $edit['label']]);
-    $this->assertRaw($message_insert);
+    $this->assertSession()->responseContains($message_insert);
     $this->assertLinkByHref('admin/structure/config_test/manage/0');
     $this->assertLinkByHref('admin/structure/config_test/manage/0/delete');
     $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete');
diff --git a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
index 446563abc8..13ab50a67e 100644
--- a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
@@ -190,7 +190,7 @@ public function testExportImport() {
     $this->assertText('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();
@@ -211,7 +211,7 @@ public function testExportImport() {
     $this->assertText('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 df904e56f7..71d2ef9717 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php
@@ -121,11 +121,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->assertFieldById('edit-submit', t('Import all'));
 
     // Import and verify that both do not appear anymore.
@@ -195,9 +195,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->drupalPostForm(NULL, [], t('Import all'));
@@ -473,7 +473,7 @@ public function testEntityBundleDelete() {
     // removal.
     $this->drupalPostForm(NULL, [], t('Import all'));
     $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]);
-    $this->assertRaw($validation_message);
+    $this->assertSession()->responseContains($validation_message);
     $this->assertText(new FormattableMarkup('node.type.@type', ['@type' => $node_type->id()]));
     $this->assertText(new FormattableMarkup('field.field.node.@type.body', ['@type' => $node_type->id()]));
     $this->assertText(new FormattableMarkup('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()]));
diff --git a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
index 368fd053c1..0ac1522cfe 100644
--- a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
@@ -59,7 +59,7 @@ public function testImport() {
     $directory = Settings::get('config_sync_directory');
     \Drupal::service('file_system')->chmod($directory, 0555);
     $this->drupalGet('admin/config/development/configuration/full/import');
-    $this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
+    $this->assertSession()->responseContains(t('The directory %directory is not writable.', ['%directory' => $directory]));
     // Ensure submit button for \Drupal\config\Form\ConfigImportForm is
     // disabled.
     $submit_is_disabled = $this->cssSelect('form.config-import-form input[type="submit"]:disabled');
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
index 91461b50c3..2642027541 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php
@@ -132,7 +132,7 @@ public function testPreExistingConfigInstall() {
     // config_install_fail_test.
     // @see \Drupal\system\Form\ModulesListForm::submitForm()
     $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE], t('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->drupalPostForm('admin/modules/uninstall', ['uninstall[config_test]' => TRUE], t('Uninstall'));
@@ -144,7 +144,7 @@ public function testPreExistingConfigInstall() {
     // @see \Drupal\system\Form\ModulesListConfirmForm::submitForm()
     $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install'));
     $this->drupalPostForm(NULL, [], t('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.
@@ -157,7 +157,7 @@ public function testPreExistingConfigInstall() {
       ->save();
 
     $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('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
@@ -166,7 +166,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 {
@@ -189,11 +189,11 @@ public function testUnmetDependenciesInstall() {
     // not depend on config_test and order is important.
     $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE], t('Install'));
     $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('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->drupalPostForm('admin/modules', ['modules[config_test_language][enable]' => TRUE], t('Install'));
     $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('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->drupalPostForm('admin/modules', ['modules[config_other_module_config_test][enable]' => TRUE], t('Install'));
     $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install'));
@@ -216,7 +216,7 @@ public function testConfigModuleRequirements() {
       // Ignore failed deletes.
     }
     $this->drupalGet('/admin/reports/status');
-    $this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory]));
+    $this->assertSession()->responseContains(t('The directory %directory does not exist.', ['%directory' => $directory]));
   }
 
 }
diff --git a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
index 250ea06b17..3f8e33f1f4 100644
--- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
@@ -74,13 +74,13 @@ public function testImport() {
     $this->assertNull($storage->load('first'));
     $edit['import'] = "id: first\n" . $edit['import'];
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
+    $this->assertSession()->responseContains(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
     $this->drupalPostForm(NULL, [], t('Confirm'));
     $entity = $storage->load('first');
     $this->assertIdentical($entity->label(), 'First');
     $this->assertIdentical($entity->id(), 'first');
     $this->assertTrue($entity->status());
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->responseContains(t('The configuration was imported successfully.'));
 
     // Attempt an import with an existing ID but missing UUID.
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
@@ -94,9 +94,9 @@ public function testImport() {
     // Attempt an import with a custom ID.
     $edit['custom_entity_id'] = 'custom_id';
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
+    $this->assertSession()->responseContains(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
     $this->drupalPostForm(NULL, [], t('Confirm'));
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->responseContains(t('The configuration was imported successfully.'));
 
     // Perform an import with a unique ID and UUID.
     $import = <<<EOD
@@ -113,10 +113,10 @@ public function testImport() {
     $second_uuid = $uuid->generate();
     $edit['import'] .= "\nuuid: " . $second_uuid;
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+    $this->assertSession()->responseContains(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
     $this->drupalPostForm(NULL, [], t('Confirm'));
     $entity = $storage->load('second');
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->responseContains(t('The configuration was imported successfully.'));
     $this->assertIdentical($entity->label(), 'Second');
     $this->assertIdentical($entity->id(), 'second');
     $this->assertFalse($entity->status());
@@ -136,10 +136,10 @@ public function testImport() {
       'import' => $import,
     ];
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
+    $this->assertSession()->responseContains(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
     $this->drupalPostForm(NULL, [], t('Confirm'));
     $entity = $storage->load('second');
-    $this->assertRaw(t('The configuration was imported successfully.'));
+    $this->assertSession()->responseContains(t('The configuration was imported successfully.'));
     $this->assertIdentical($entity->label(), 'Second updated');
 
     // Try to perform an update which adds missing dependencies.
@@ -159,7 +159,7 @@ public function testImport() {
       'import' => $import,
     ];
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
+    $this->assertSession()->responseContains(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
 
     // Try to preform an update which would create a PHP object if Yaml parsing
     // not securely set up.
@@ -180,13 +180,13 @@ public function testImport() {
     if (extension_loaded('yaml')) {
       // If the yaml extension is loaded it will work but not create the PHP
       // object.
-      $this->assertRaw(t('Are you sure you want to update the %name @type?', [
+      $this->assertSession()->responseContains(t('Are you sure you want to update the %name @type?', [
         '%name' => 'second',
         '@type' => 'test configuration',
       ]));
       $this->drupalPostForm(NULL, [], t('Confirm'));
       $entity = $storage->load('second');
-      $this->assertRaw(t('The configuration was imported successfully.'));
+      $this->assertSession()->responseContains(t('The configuration was imported successfully.'));
       $this->assertIsString($entity->label());
       $this->assertStringContainsString('ObjectSerialization', $entity->label(), 'Label contains serialized object');
     }
@@ -213,7 +213,7 @@ public function testImportSimpleConfiguration() {
       'import' => Yaml::encode($config->get()),
     ];
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
-    $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
+    $this->assertSession()->responseContains(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
     $this->drupalPostForm(NULL, [], t('Confirm'));
     $this->drupalGet('');
     $this->assertText('Test simple import');
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
index 8de59f805a..9f95e236dc 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
@@ -110,7 +110,7 @@ protected function doBlockListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -157,7 +157,7 @@ protected function doMenuListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -182,7 +182,7 @@ protected function doVocabularyListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -207,7 +207,7 @@ public function doCustomContentTypeListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -231,7 +231,7 @@ public function doContactFormsListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -254,7 +254,7 @@ public function doContentTypeListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -278,7 +278,7 @@ public function doFormatsListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -302,7 +302,7 @@ public function doShortcutListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -323,7 +323,7 @@ public function doUserRoleListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -343,7 +343,7 @@ public function doLanguageListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -359,7 +359,7 @@ public function doImageStyleListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -372,7 +372,7 @@ public function doResponsiveImageListTest() {
     $edit['fallback_image_style'] = 'thumbnail';
 
     $this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
-    $this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
 
     // Get the responsive image style listing.
     $this->drupalGet('admin/config/media/responsive-image-style');
@@ -383,7 +383,7 @@ public function doResponsiveImageListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -435,7 +435,7 @@ public function doFieldListTest() {
 
       // Test if the link to translate actually goes to the translate page.
       $this->drupalGet($translate_link);
-      $this->assertRaw('<th>' . t('Language') . '</th>');
+      $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
     }
   }
 
@@ -452,7 +452,7 @@ public function doDateFormatListTest() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
@@ -471,7 +471,7 @@ public function doSettingsPageTest($link) {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
   }
 
   /**
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
index 5fe5916ad9..d5b1c18214 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
@@ -122,8 +122,8 @@ public function testMapperListPage() {
 
       $title = $test_entity->label() . ' ' . $entity_type->getSingularLabel();
       $title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
-      $this->assertRaw($title);
-      $this->assertRaw('<th>' . t('Language') . '</th>');
+      $this->assertSession()->responseContains($title);
+      $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
 
       $this->drupalGet($base_url);
       $this->assertLink(t('Translate @title', ['@title' => $entity_type->getSingularLabel()]));
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php
index 85ee670e56..80760d31f6 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(t('Add'));
 
     // Make sure original text is present on this page.
-    $this->assertRaw($site_name);
-    $this->assertRaw($site_slogan);
+    $this->assertSession()->responseContains($site_name);
+    $this->assertSession()->responseContains($site_slogan);
 
     // Update site name and slogan for French.
     $edit = [
@@ -171,7 +171,7 @@ public function testSiteInformationTranslationUi() {
     ];
 
     $this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
-    $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
+    $this->assertSession()->responseContains(t('Successfully saved @language translation.', ['@language' => 'French']));
 
     // Check for edit, delete links (and no 'add' link) for French language.
     $this->assertNoLinkByHref("$translation_base_url/fr/add");
@@ -188,8 +188,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()->responseContains($fr_site_name);
+    $this->assertSession()->responseContains($fr_site_slogan);
 
     // Visit French site to ensure base language string present as source.
     $this->drupalGet("fr/$translation_base_url/fr/edit");
@@ -270,7 +270,7 @@ public function testSourceValueDuplicateSave() {
       'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save translation'));
-    $this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French']));
+    $this->assertSession()->responseContains(t('Successfully updated @language translation.', ['@language' => 'French']));
     $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
 
     // Expect only slogan in language specific file.
@@ -411,12 +411,12 @@ public function testContactConfigEntityTranslation() {
       $replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => mb_strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()];
 
       $this->drupalGet("$translation_base_url/$langcode/delete");
-      $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
+      $this->assertSession()->responseContains(t('Are you sure you want to delete the @language translation of %label?', $replacements));
       // Assert link back to list page to cancel delete is present.
       $this->assertLinkByHref($translation_base_url);
 
       $this->drupalPostForm(NULL, [], t('Delete'));
-      $this->assertRaw(t('@language translation of %label was deleted', $replacements));
+      $this->assertSession()->responseContains(t('@language translation of %label was deleted', $replacements));
       $this->assertLinkByHref("$translation_base_url/$langcode/add");
       $this->assertNoLinkByHref("translation_base_url/$langcode/edit");
       $this->assertNoLinkByHref("$translation_base_url/$langcode/delete");
@@ -479,7 +479,7 @@ public function testDateFormatTranslation() {
       $this->assertText($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 = [
@@ -608,8 +608,8 @@ public function testViewsTranslationUI() {
     $this->clickLink(t('Add'));
 
     // Make sure original text is present on this page.
-    $this->assertRaw($description);
-    $this->assertRaw($human_readable_name);
+    $this->assertSession()->responseContains($description);
+    $this->assertSession()->responseContains($human_readable_name);
 
     // Update Views Fields for French.
     $edit = [
@@ -619,7 +619,7 @@ public function testViewsTranslationUI() {
       'translation[config_names][views.view.frontpage][display][default][display_options][title]' => $display_options_master . " FR",
     ];
     $this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
-    $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
+    $this->assertSession()->responseContains(t('Successfully saved @language translation.', ['@language' => 'French']));
 
     // Check for edit, delete links (and no 'add' link) for French language.
     $this->assertNoLinkByHref("$translation_base_url/fr/add");
@@ -668,7 +668,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->assertNoRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
@@ -701,7 +701,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()->responseContains($description);
     $this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', $field_value);
     $this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', $field_value_plural);
     $this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', '');
@@ -861,18 +861,18 @@ public function testSingleLanguageUI() {
 
     // Delete French language
     $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
 
     // Change default language to Tamil.
     $edit = [
       'site_default_language' => 'ta',
     ];
     $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
-    $this->assertRaw(t('Configuration saved.'));
+    $this->assertSession()->responseContains(t('Configuration saved.'));
 
     // Delete English language
     $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
 
     // Visit account setting translation page, this should not
     // throw any notices.
@@ -1071,7 +1071,7 @@ public function testNodeFieldTranslation() {
 
     // Check that the translations are saved.
     $this->clickLink('Add');
-    $this->assertRaw('FR label');
+    $this->assertSession()->responseContains('FR label');
   }
 
   /**
@@ -1120,7 +1120,7 @@ protected function setSiteInformation($site_name, $site_slogan) {
       'site_slogan' => $site_slogan,
     ];
     $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
-    $this->assertRaw(t('The configuration options have been saved.'));
+    $this->assertSession()->responseContains(t('The configuration options have been saved.'));
   }
 
   /**
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
index 50e169f09f..0d61a44f2a 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
@@ -54,7 +54,7 @@ public function testTranslateOperationInViewListUi() {
 
     // Test if the link to translate actually goes to the translate page.
     $this->drupalGet($translate_link);
-    $this->assertRaw('<th>' . t('Language') . '</th>');
+    $this->assertSession()->responseContains('<th>' . t('Language') . '</th>');
 
     // Test that the 'Edit' tab appears.
     $this->assertLinkByHref('admin/structure/views/view/test_view');
diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
index d74dec9376..7e8467d7d0 100644
--- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php
@@ -105,7 +105,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->assertNoRaw($this->webUser->getEmail());
   }
@@ -119,7 +119,7 @@ public function testPersonalContactAccess() {
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertSession()->statusCodeEquals(200);
     // Check the page title is properly displayed.
-    $this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()]));
+    $this->assertSession()->responseContains(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()]));
 
     // Test denied access to admin user's own contact form.
     $this->drupalLogout();
@@ -247,7 +247,7 @@ public function testPersonalContactFlood() {
 
     // Submit contact form one over limit.
     $this->submitPersonalContact($this->contactUser);
-    $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]), 'Normal user denied access to flooded contact form.');
+    $this->assertSession()->responseContains(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]), 'Normal user denied access to flooded contact form.');
 
     // Test that the admin user can still access the contact form even though
     // the flood limit was reached.
diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
index 3fb719e062..e4bda13a4e 100644
--- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
+++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php
@@ -150,7 +150,7 @@ public function testSiteWideContact() {
     $invalid_recipients = ['invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'];
     foreach ($invalid_recipients as $invalid_recipient) {
       $this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE);
-      $this->assertRaw(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient]));
+      $this->assertSession()->responseContains(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient]));
     }
 
     // Test validation of empty form and recipients fields.
@@ -225,7 +225,7 @@ public function testSiteWideContact() {
     // Try adding a form that already exists.
     $this->addContactForm($name, $label, '', '', FALSE);
     $this->assertNoText(t('Contact form @label has been added.', ['@label' => $label]));
-    $this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
+    $this->assertSession()->responseContains(t('The machine-readable name is already in use. It must be unique.'));
 
     $this->drupalLogout();
 
@@ -247,7 +247,7 @@ public function testSiteWideContact() {
     $this->assertText(t('Your email address field is required.'));
 
     $this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
-    $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
+    $this->assertSession()->responseContains(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
 
     $this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64));
     $this->assertText(t('Subject field is required.'));
@@ -275,7 +275,7 @@ public function testSiteWideContact() {
     }
     // Submit contact form one over limit.
     $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
-    $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')]));
+    $this->assertSession()->responseContains(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')]));
 
     // Test listing controller.
     $this->drupalLogin($admin_user);
@@ -473,7 +473,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');
   }
 
   /**
@@ -580,7 +580,7 @@ public function deleteContactForms() {
       }
       else {
         $this->drupalPostForm("admin/structure/contact/manage/$id/delete", [], t('Delete'));
-        $this->assertRaw(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()]));
+        $this->assertSession()->responseContains(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()]));
         $this->assertNull(ContactForm::load($id), new FormattableMarkup('Form %contact_form not found', ['%contact_form' => $contact_form->label()]));
       }
     }
diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php
index 8999dae122..9bf89bd1e7 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->assertText('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()->responseContains('Save');
     $this->drupalPostForm(NULL, [
       'title[0][value]' => 'Test',
     ], t('Save'));
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
index b958fa1af6..a8ae62aca4 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
@@ -127,7 +127,7 @@ public function testContentTranslationContextualLinks() {
     $this->drupalLogin($this->translator);
     $translate_link = 'node/' . $node->id() . '/translations';
     $this->drupalGet($translate_link);
-    $this->assertRaw(t('Translations of %label', ['%label' => $node->label()]), 'The contextual link leads to the translate page.');
+    $this->assertSession()->responseContains(t('Translations of %label', ['%label' => $node->label()]), 'The contextual link leads to the translate page.');
   }
 
 }
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php
index bf9c41b939..b389577fd4 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->drupalPostForm('admin/structure/types/add', $edit, t('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 a68b99d53a..bc556b8269 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
@@ -140,7 +140,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()->responseContains('<title>Edit Article english_title | Drupal</title>');
     // Upload and image after changing the node language.
     $images = $this->drupalGetTestFiles('image')[1];
     $edit = [
@@ -150,7 +150,7 @@ public function testTitleDoesNotChangesOnChangingLanguageWidgetAndTriggeringAjax
     $this->drupalPostForm(NULL, $edit, t('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()->responseContains('<title>Edit Article english_title | Drupal</title>');
     $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 162c5d1f81..d32df087b2 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -116,7 +116,7 @@ protected function doTestBasicTranslation() {
     // Assert that HTML is not escaped unexpectedly.
     if ($this->testHTMLEscapeForAllLanguages) {
       $this->assertNoRaw('&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
@@ -511,7 +511,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 0df0336349..2ce3d2d4d8 100644
--- a/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
+++ b/core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
@@ -150,7 +150,7 @@ public function testDifferentPermissions() {
     // Get a page where contextual links are directly rendered.
     $this->drupalGet(Url::fromRoute('menu_test.contextual_test'));
     $this->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 2c5ed0b3db..dc0a3afca3 100644
--- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
+++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
@@ -77,7 +77,7 @@ public function testDateField() {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-      $this->assertRaw($date->format($date_format));
+      $this->assertSession()->responseContains($date->format($date_format));
       $this->assertNoRaw($date->format($time_format));
 
       // Verify the date doesn't change if using a timezone that is UTC+12 when
@@ -272,8 +272,8 @@ public function testDatetimeField() {
     preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
     $id = $match[1];
     $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-    $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 10e48dbdbd..d95898e529 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->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-      $this->assertRaw($start_date->format($date_format));
+      $this->assertSession()->responseContains($start_date->format($date_format));
       $this->assertNoRaw($start_date->format($time_format));
-      $this->assertRaw($end_date->format($date_format));
+      $this->assertSession()->responseContains($end_date->format($date_format));
       $this->assertNoRaw($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->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-    $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->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-    $this->assertRaw($start_date->format($date_format));
+    $this->assertSession()->responseContains($start_date->format($date_format));
     $this->assertNoRaw($start_date->format($time_format));
-    $this->assertRaw($end_date->format($date_format));
+    $this->assertSession()->responseContains($end_date->format($date_format));
     $this->assertNoRaw($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 c8ebd31f59..07add9933f 100644
--- a/core/modules/dblog/tests/src/Functional/DbLogTest.php
+++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php
@@ -126,10 +126,10 @@ public function testLogEventPage() {
     $this->assertLinkByHref($context['referer']);
 
     // Verify hostname.
-    $this->assertRaw($context['ip'], 'Found hostname on the detail page.');
+    $this->assertSession()->responseContains($context['ip'], 'Found hostname on the detail page.');
 
     // Verify location.
-    $this->assertRaw($context['request_uri'], 'Found location on the detail page.');
+    $this->assertSession()->responseContains($context['request_uri'], 'Found location on the detail page.');
 
     // Verify severity.
     $this->assertText('Notice', 'The severity was properly displayed on the detail page.');
@@ -383,7 +383,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);
   }
 
   /**
@@ -453,7 +453,7 @@ private function doUser() {
       $link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/'));
       $this->drupalGet($link);
       // Check for full message text on the details page.
-      $this->assertRaw($message, 'DBLog event details was found: [delete user]');
+      $this->assertSession()->responseContains($message, 'DBLog event details was found: [delete user]');
     }
     $this->assertNotEmpty($link, 'DBLog event was recorded: [delete user]');
     // Visit random URL (to generate page not found event).
@@ -823,7 +823,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->assertNoRaw("<script>alert('foo');</script>");
 
     // Make sure HTML tags are filtered out in admin/reports/dblog/event/ too.
@@ -831,7 +831,7 @@ public function testOverviewLinks() {
     $wid = Database::getConnection()->query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
     $this->drupalGet('admin/reports/dblog/event/' . $wid);
     $this->assertNoRaw("<script>alert('foo');</script>");
-    $this->assertRaw("alert('foo'); <strong>Lorem ipsum</strong>");
+    $this->assertSession()->responseContains("alert('foo'); <strong>Lorem ipsum</strong>");
   }
 
   /**
@@ -872,8 +872,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 5d2ee6547c..c1fb401780 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()->responseContains($animal);
       $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache MISS.');
       $this->drupalGet($url);
-      $this->assertRaw($animal);
+      $this->assertSession()->responseContains($animal);
       $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache 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 e2ffd5ecfb..1a54cd8a27 100644
--- a/core/modules/editor/tests/src/Functional/EditorAdminTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorAdminTest.php
@@ -72,7 +72,7 @@ public function testNoEditorAvailable() {
     $this->assertCount(1, $select_is_disabled, 'The Text Editor select is disabled.');
     $this->assertCount(1, $options, 'The Text Editor select has only one option.');
     $this->assertTrue(($options[0]->getText()) === 'None', '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.', 'Description for select present that tells users to install a text editor module.');
+    $this->assertSession()->responseContains('This option is disabled because no modules that provide a text editor are currently enabled.', 'Description for select present that tells users to install a text editor module.');
   }
 
   /**
@@ -145,14 +145,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 e054ae743d..e651ff7ce6 100644
--- a/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
@@ -99,7 +99,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEqual($uploaded_image_file_width, $max_width);
     $this->assertEqual($uploaded_image_file_height, $uploaded_image_file_height * ($uploaded_image_file_width / $max_width));
-    $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()->responseContains((string) new FormattableMarkup('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', ['%dimensions' => $max_width . 'x' . $max_height]));
 
     // Case 3: max height smaller than uploaded image: image scaled down.
     $test_image = $testing_image_list[2];
@@ -111,7 +111,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEqual($uploaded_image_file_width, $uploaded_image_file_width * ($uploaded_image_file_height / $max_height));
     $this->assertEqual($uploaded_image_file_height, $max_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()->responseContains((string) new FormattableMarkup('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', ['%dimensions' => $max_width . 'x' . $max_height]));
 
     // Case 4: max dimensions greater than uploaded image: image not scaled.
     $test_image = $testing_image_list[3];
@@ -136,7 +136,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEqual($uploaded_image_file_width, $max_width);
     $this->assertEqual($uploaded_image_file_height, $uploaded_image_file_height * ($uploaded_image_file_width / $max_width));
-    $this->assertRaw((string) new FormattableMarkup('The image was resized to fit within the maximum allowed width of %width pixels.', ['%width' => $max_width]));
+    $this->assertSession()->responseContains((string) new FormattableMarkup('The image was resized to fit within the maximum allowed width of %width pixels.', ['%width' => $max_width]));
 
     // Case 6: only max height dimension was provided and it was smaller than
     // uploaded image: image scaled down.
@@ -149,7 +149,7 @@ public function testEditorUploadImageScale() {
     list($uploaded_image_file_width, $uploaded_image_file_height) = $this->uploadImage($test_image->uri);
     $this->assertEqual($uploaded_image_file_width, $uploaded_image_file_width * ($uploaded_image_file_height / $max_height));
     $this->assertEqual($uploaded_image_file_height, $max_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()->responseContains((string) new FormattableMarkup('The image was resized to fit within the maximum allowed height of %height pixels.', ['%height' => $max_height]));
   }
 
   /**
diff --git a/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
index 076d4ac8d5..0ff75a5eeb 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 b34504e955..dc5a6187c4 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->assertFieldByName("{$field_name}[value]", '', 'Widget found.');
-    $this->assertRaw($on);
+    $this->assertSession()->responseContains($on);
     $this->assertNoText($this->field->label());
 
     // Test if we can change the on label.
@@ -147,7 +147,7 @@ public function testBooleanField() {
     $this->drupalPostForm('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name, $edit, t('Save settings'));
     // Check if we see the updated labels in the creation form.
     $this->drupalGet('entity_test/add');
-    $this->assertRaw($on);
+    $this->assertSession()->responseContains($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 11b6342633..c60c7116cb 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->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.');
-    $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->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-    $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 124fe9d7b6..89c85663d7 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php
@@ -151,8 +151,8 @@ public function testFieldAdminHandler() {
     $result = $this->xpath('//input[@name="field_test_entity_ref_field[0][target_id]" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/node/views/")]');
     $target_url = $this->getAbsoluteUrl($result[0]->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()->responseContains($node1->getTitle() . ' (' . $node1->id() . ')');
+    $this->assertSession()->responseContains($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 cc200dfd98..429a9ffb2c 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php
@@ -84,7 +84,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() . ')', 'The default value is selected in instance settings page');
+    $this->assertSession()->responseContains('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')', 'The default value is selected in instance settings page');
 
     // 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/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php
index dba8c35a69..14ab949640 100644
--- a/core/modules/field/tests/src/Functional/FormTest.php
+++ b/core/modules/field/tests/src/Functional/FormTest.php
@@ -134,7 +134,7 @@ public function testFieldFormSingle() {
       "{$field_name}[0][value]" => -1,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $this->field['label']]), 'Field validation fails with invalid input.');
+    $this->assertSession()->responseContains(t('%name does not accept the value -1.', ['%name' => $this->field['label']]), 'Field validation fails with invalid input.');
     // TODO : check that the correct field is flagged for error.
 
     // Create an entity
@@ -225,7 +225,7 @@ public function testFieldFormSingleRequired() {
     // Submit with missing required value.
     $edit = [];
     $this->drupalPostForm('entity_test/add', $edit, t('Save'));
-    $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
 
     // Create an entity
     $value = mt_rand(1, 127);
@@ -245,7 +245,7 @@ public function testFieldFormSingleRequired() {
       "{$field_name}[0][value]" => $value,
     ];
     $this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
-    $this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => $this->field['label']]), 'Required field with no value fails validation');
   }
 
   public function testFieldFormUnlimited() {
@@ -452,7 +452,7 @@ public function testFieldFormMultipleWidget() {
     // Submit the form with more values than the field accepts.
     $edit = [$field_name => '1, 2, 3, 4, 5'];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.');
+    $this->assertSession()->responseContains('this field cannot hold more than 4 values', 'Form validation failed.');
     // Check that the field values were not submitted.
     $this->assertFieldValues($entity_init, $field_name, [1, 2, 3]);
 
diff --git a/core/modules/field/tests/src/Functional/NestedFormTest.php b/core/modules/field/tests/src/Functional/NestedFormTest.php
index 8cf509ece9..c6379b7203 100644
--- a/core/modules/field/tests/src/Functional/NestedFormTest.php
+++ b/core/modules/field/tests/src/Functional/NestedFormTest.php
@@ -125,14 +125,14 @@ public function testNestedFieldForm() {
       'field_unlimited[1][value]' => -1,
     ];
     $this->drupalPostForm('test-entity/nested/1/2', $edit, t('Save'));
-    $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 1: the field validation error was reported.');
+    $this->assertSession()->responseContains(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 1: the field validation error was reported.');
     $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', [':id' => 'edit-field-unlimited-1-value']);
     $this->assertCount(1, $error_field, 'Entity 1: the error was flagged on the correct element.');
     $edit = [
       'entity_2[field_unlimited][1][value]' => -1,
     ];
     $this->drupalPostForm('test-entity/nested/1/2', $edit, t('Save'));
-    $this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 2: the field validation error was reported.');
+    $this->assertSession()->responseContains(t('%label does not accept the value -1', ['%label' => 'Unlimited field']), 'Entity 2: the field validation error was reported.');
     $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', [':id' => 'edit-entity-2-field-unlimited-1-value']);
     $this->assertCount(1, $error_field, 'Entity 2: the error was flagged on the correct element.');
 
diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
index e4e9358c71..e4fb808216 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->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
-    $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->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
-    $this->assertRaw($value, 'Value is displayed.');
+    $this->assertSession()->responseContains($value, 'Value is displayed.');
 
     // Try to create entries with more than one decimal separator; assert fail.
     $wrong_entries = [
@@ -104,7 +104,7 @@ public function testNumberDecimalField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->drupalPostForm(NULL, $edit, t('Save'));
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with more than one decimal point.');
+      $this->assertSession()->responseContains(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with more than one decimal point.');
     }
 
     // Try to create entries with minus sign not in the first position.
@@ -122,7 +122,7 @@ public function testNumberDecimalField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->drupalPostForm(NULL, $edit, t('Save'));
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with minus sign in the wrong position.');
+      $this->assertSession()->responseContains(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save decimal value with minus sign in the wrong position.');
     }
   }
 
@@ -191,7 +191,7 @@ public function testNumberIntegerField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
-    $this->assertRaw('placeholder="4"');
+    $this->assertSession()->responseContains('placeholder="4"');
 
     // Submit a valid integer
     $value = rand($minimum, $maximum);
@@ -209,7 +209,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => $minimum - 1,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('%name must be higher than or equal to %minimum.', ['%name' => $field_name, '%minimum' => $minimum]), 'Correctly failed to save integer value less than minimum allowed value.');
+    $this->assertSession()->responseContains(t('%name must be higher than or equal to %minimum.', ['%name' => $field_name, '%minimum' => $minimum]), 'Correctly failed to save integer value less than minimum allowed value.');
 
     // Try to set a decimal value
     $this->drupalGet('entity_test/add');
@@ -217,7 +217,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => 1.5,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('%name is not a valid number.', ['%name' => $field_name]), 'Correctly failed to save decimal value to integer field.');
+    $this->assertSession()->responseContains(t('%name is not a valid number.', ['%name' => $field_name]), 'Correctly failed to save decimal value to integer field.');
 
     // Try to set a value above the maximum value
     $this->drupalGet('entity_test/add');
@@ -225,7 +225,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => $maximum + 1,
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('%name must be lower than or equal to %maximum.', ['%name' => $field_name, '%maximum' => $maximum]), 'Correctly failed to save integer value greater than maximum allowed value.');
+    $this->assertSession()->responseContains(t('%name must be lower than or equal to %maximum.', ['%name' => $field_name, '%maximum' => $maximum]), 'Correctly failed to save integer value greater than maximum allowed value.');
 
     // Try to set a wrong integer value.
     $this->drupalGet('entity_test/add');
@@ -233,7 +233,7 @@ public function testNumberIntegerField() {
       "{$field_name}[0][value]" => '20-40',
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save wrong integer value.');
+    $this->assertSession()->responseContains(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save wrong integer value.');
 
     // Test with valid entries.
     $valid_entries = [
@@ -251,7 +251,7 @@ public function testNumberIntegerField() {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
-      $this->assertRaw($valid_entry, 'Value is displayed.');
+      $this->assertSession()->responseContains($valid_entry, 'Value is displayed.');
       $this->assertNoFieldByXpath('//div[@content="' . $valid_entry . '"]', NULL, 'The "content" attribute is not present since the Prefix is not being displayed');
     }
 
@@ -316,7 +316,7 @@ public function testNumberFloatField() {
     // Display creation form.
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
-    $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';
@@ -331,7 +331,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 = [
@@ -348,7 +348,7 @@ public function testNumberFloatField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->drupalPostForm(NULL, $edit, t('Save'));
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with more than one decimal point.');
+      $this->assertSession()->responseContains(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with more than one decimal point.');
     }
 
     // Try to create entries with minus sign not in the first position.
@@ -366,7 +366,7 @@ public function testNumberFloatField() {
         "{$field_name}[0][value]" => $wrong_entry,
       ];
       $this->drupalPostForm(NULL, $edit, t('Save'));
-      $this->assertRaw(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with minus sign in the wrong position.');
+      $this->assertSession()->responseContains(t('%name must be a number.', ['%name' => $field_name]), 'Correctly failed to save float value with minus sign in the wrong position.');
     }
   }
 
@@ -434,7 +434,7 @@ public function assertSetMinimumValue($field, $minimum_value) {
     // Check if an error message is shown.
     $this->assertNoRaw(t('%name is not a valid number.', ['%name' => t('Minimum')]), 'Saved ' . gettype($minimum_value) . '  value as minimal value on a ' . $field->getType() . ' field');
     // Check if a success message is shown.
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
+    $this->assertSession()->responseContains(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
     // Check if the minimum value was actually set.
     $this->drupalGet($field_configuration_url);
     $this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) . '  value was set on a ' . $field->getType() . ' field.');
diff --git a/core/modules/field/tests/src/Functional/String/StringFieldTest.php b/core/modules/field/tests/src/Functional/String/StringFieldTest.php
index 15c0f43644..83fb65ad15 100644
--- a/core/modules/field/tests/src/Functional/String/StringFieldTest.php
+++ b/core/modules/field/tests/src/Functional/String/StringFieldTest.php
@@ -88,7 +88,7 @@ public function _testTextfieldWidgets($field_type, $widget_type) {
     $this->drupalGet('entity_test/add');
     $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
     $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed');
-    $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 00ada09373..afae96d130 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", 'Prefix and suffix added');
-    $this->assertRaw((string) $random_integer);
+    $this->assertSession()->responseContains("$prefix$float_formatted$suffix", 'Prefix and suffix added');
+    $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, 'Random integer formatted');
+    $this->assertSession()->responseContains($integer_formatted, 'Random 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 9b37084ed4..52e9169c47 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->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+    $this->assertSession()->responseContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
 
     // Test adding a view mode.
     $edit = [
@@ -77,7 +77,7 @@ public function testEntityViewModeUI() {
       'label' => $this->randomString(),
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Saved the %label view mode.', ['%label' => $edit['label']]));
 
     // Test editing the view mode.
     $this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
@@ -92,9 +92,9 @@ public function testEntityViewModeUI() {
 
     // Test deleting the view mode.
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the view mode %label?', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the view mode %label?', ['%label' => $edit['label']]));
     $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('The view mode %label has been deleted.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('The view mode %label has been deleted.', ['%label' => $edit['label']]));
   }
 
   /**
@@ -123,7 +123,7 @@ public function testEntityFormModeUI() {
       'label' => $this->randomString(),
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+    $this->assertSession()->responseContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
 
     // Test adding a form mode.
     $edit = [
@@ -131,7 +131,7 @@ public function testEntityFormModeUI() {
       'label' => $this->randomString(),
     ];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Saved the %label form mode.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Saved the %label form mode.', ['%label' => $edit['label']]));
 
     // Test editing the form mode.
     $this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
@@ -146,9 +146,9 @@ public function testEntityFormModeUI() {
 
     // Test deleting the form mode.
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the form mode %label?', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the form mode %label?', ['%label' => $edit['label']]));
     $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
+    $this->assertSession()->responseContains(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
   }
 
   /**
diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
index a3cb5e6164..222434f90e 100644
--- a/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
+++ b/core/modules/field_ui/tests/src/Functional/FieldUIIndentationTest.php
@@ -40,7 +40,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/ManageDisplayTest.php b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
index de9a910f8c..458b0c67f7 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
@@ -192,7 +192,7 @@ public function testNoFieldsDisplayOverview() {
     ])->save();
 
     $this->drupalGet('admin/structure/types/manage/no_fields/display');
-    $this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString()]));
+    $this->assertSession()->responseContains(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString()]));
   }
 
   /**
diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
index 730599008b..cb77b1450f 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
@@ -154,7 +154,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>', new FormattableMarkup('%table_header table header was found.', ['%table_header' => $table_header]));
+      $this->assertSession()->responseContains($table_header . '</th>', new FormattableMarkup('%table_header table header was found.', ['%table_header' => $table_header]));
     }
 
     // Test the "Add field" action link.
@@ -236,7 +236,7 @@ public function updateField() {
   public function addExistingField() {
     // Check "Re-use existing field" appears.
     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
-    $this->assertRaw(t('Re-use an existing field'), '"Re-use existing field" was found.');
+    $this->assertSession()->responseContains(t('Re-use an existing field'), '"Re-use existing field" was found.');
 
     // Check that fields of other entity types (here, the 'comment_body' field)
     // do not show up in the "Re-use existing field" list.
@@ -294,7 +294,7 @@ public function cardinalitySettings() {
       'cardinality_number' => 1,
     ];
     $this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
-    $this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 2]), 'Correctly failed to set cardinality lower than highest delta.');
+    $this->assertSession()->responseContains(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 2]), 'Correctly failed to set cardinality lower than highest delta.');
 
     // Create a second entity with three values.
     $edit = ['title[0][value]' => 'Cardinality 3', 'body[0][value]' => 'Body 1', 'body[1][value]' => 'Body 2', 'body[2][value]' => 'Body 3'];
@@ -317,14 +317,14 @@ public function cardinalitySettings() {
       'cardinality_number' => 1,
     ];
     $this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
-    $this->assertRaw(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 2]), 'Correctly failed to set cardinality lower than highest delta.');
+    $this->assertSession()->responseContains(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 2]), 'Correctly failed to set cardinality lower than highest delta.');
 
     $edit = [
       'cardinality' => 'number',
       'cardinality_number' => 2,
     ];
     $this->drupalPostForm($field_edit_path, $edit, t('Save field settings'));
-    $this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 3]), 'Correctly failed to set cardinality lower than highest delta.');
+    $this->assertSession()->responseContains(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 3]), 'Correctly failed to set cardinality lower than highest delta.');
 
     $edit = [
       'cardinality' => 'number',
@@ -360,7 +360,7 @@ protected function addPersistentFieldStorage() {
     }
     // Check "Re-use existing field" appears.
     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
-    $this->assertRaw(t('Re-use an existing field'), '"Re-use existing field" was found.');
+    $this->assertSession()->responseContains(t('Re-use an existing field'), '"Re-use existing field" was found.');
 
     // Ensure that we test with a label that contains HTML.
     $label = $this->randomString(4) . '<br/>' . $this->randomString(4);
@@ -671,7 +671,7 @@ public function testExternalDestinations() {
     // The external redirect should not fire.
     $this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options);
     $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>.');
   }
 
   /**
@@ -731,8 +731,8 @@ public function testHelpDescriptions() {
     $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_tags', $edit, t('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 de125d1854..bce5775e52 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
@@ -45,17 +45,17 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
 
     // First step: 'Add field' page.
     $this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
-    $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]), 'Storage settings page was displayed.');
+    $this->assertSession()->responseContains(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]), 'Storage settings page was displayed.');
     // Test Breadcrumbs.
     $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
 
     // Second step: 'Storage settings' form.
     $this->drupalPostForm(NULL, $storage_edit, t('Save field settings'));
-    $this->assertRaw(t('Updated field %label field settings.', ['%label' => $label]), 'Redirected to field settings page.');
+    $this->assertSession()->responseContains(t('Updated field %label field settings.', ['%label' => $label]), 'Redirected to field settings page.');
 
     // Third step: 'Field settings' form.
     $this->drupalPostForm(NULL, $field_edit, t('Save settings'));
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
+    $this->assertSession()->responseContains(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
 
     // Check that the field appears in the overview form.
     $this->assertFieldByXPath('//table[@id="field-overview"]//tr/td[1]', $label, 'Field was created and appears in the overview page.');
@@ -86,12 +86,12 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
     $this->drupalPostForm("$bundle_path/fields/add-field", $initial_edit, t('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', 'The field config edit form is present.');
+    $this->assertSession()->responseContains('field-config-edit-form', 'The field config edit form is present.');
     $this->assertNoRaw('&amp;lt;', 'The page does not have double escaped HTML tags.');
 
     // Second step: 'Field settings' form.
     $this->drupalPostForm(NULL, $field_edit, t('Save settings'));
-    $this->assertRaw(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
+    $this->assertSession()->responseContains(t('Saved %label configuration.', ['%label' => $label]), 'Redirected to "Manage fields" page.');
 
     // Check that the field appears in the overview form.
     $this->assertFieldByXPath('//table[@id="field-overview"]//tr/td[1]', $label, 'Field was created and appears in the overview page.');
@@ -112,14 +112,14 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
   public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) {
     // Display confirmation form.
     $this->drupalGet("$bundle_path/fields/$field_name/delete");
-    $this->assertRaw(t('Are you sure you want to delete the field %label', ['%label' => $label]), 'Delete confirmation was found.');
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the field %label', ['%label' => $label]), 'Delete confirmation was found.');
 
     // Test Breadcrumbs.
     $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
 
     // Submit confirmation form.
     $this->drupalPostForm(NULL, [], t('Delete'));
-    $this->assertRaw(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label]), 'Delete message was found.');
+    $this->assertSession()->responseContains(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label]), 'Delete message was found.');
 
     // Check that the field does not appear in the overview form.
     $this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, 'Field does not appear in the overview page.');
diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php
index 35d2589323..cd8f18bb76 100644
--- a/core/modules/file/tests/src/Functional/DownloadTest.php
+++ b/core/modules/file/tests/src/Functional/DownloadTest.php
@@ -175,7 +175,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 922985cb4e..14133e5da5 100644
--- a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
@@ -79,7 +79,7 @@ public function testNodeDisplay() {
       '#file' => $node_file,
     ];
     $default_output = \Drupal::service('renderer')->renderRoot($file_link);
-    $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Default formatter displaying correctly on full node view.');
 
     // Turn the "display" option off and check that the file is no longer displayed.
     $edit = [$field_name . '[0][display]' => FALSE];
@@ -97,7 +97,7 @@ public function testNodeDisplay() {
     $this->assertText($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.
@@ -110,8 +110,8 @@ public function testNodeDisplay() {
     $edit[$field_name . '[1][display]'] = FALSE;
     $this->drupalPostForm(NULL, $edit, t('Preview'));
     $this->clickLink(t('Back to content editing'));
-    $this->assertRaw($field_name . '[0][display]', 'First file appears as expected.');
-    $this->assertRaw($field_name . '[1][display]', 'Second file appears as expected.');
+    $this->assertSession()->responseContains($field_name . '[0][display]', 'First file appears as expected.');
+    $this->assertSession()->responseContains($field_name . '[1][display]', 'Second file appears as expected.');
     $this->assertSession()->responseContains($field_name . '[1][description]', 'Description of second file appears as expected.');
 
     // Check that the file fields don't contain duplicate HTML IDs.
diff --git a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
index 51698a6257..373ae3d713 100644
--- a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php
@@ -36,7 +36,7 @@ public function testRequired() {
     $edit = [];
     $edit['title[0][value]'] = $this->randomMachineName();
     $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save'));
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required file field was empty.');
+    $this->assertSession()->responseContains(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required file field was empty.');
 
     // Create a new node with the uploaded file.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@@ -57,7 +57,7 @@ public function testRequired() {
     $edit = [];
     $edit['title[0][value]'] = $this->randomMachineName();
     $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save'));
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required multiple value file field was empty.');
+    $this->assertSession()->responseContains(t('@title field is required.', ['@title' => $field->getLabel()]), 'Node save failed when required multiple value file field was empty.');
 
     // Create a new node with the uploaded file into the multivalue field.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@@ -104,7 +104,7 @@ public function testFileMaxSize() {
       // Check that uploading the large file fails (1M limit).
       $this->uploadNodeFile($large_file, $field_name, $type_name);
       $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)]);
-      $this->assertRaw($error_message, new FormattableMarkup('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize]));
+      $this->assertSession()->responseContains($error_message, new FormattableMarkup('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => $max_filesize]));
     }
 
     // Turn off the max filesize.
@@ -148,7 +148,7 @@ public function testFileExtension() {
     // Check that the file with the wrong extension cannot be uploaded.
     $this->uploadNodeFile($test_file, $field_name, $type_name);
     $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
-    $this->assertRaw($error_message, 'Node save failed when file uploaded with the wrong extension.');
+    $this->assertSession()->responseContains($error_message, 'Node save failed when file uploaded with the wrong extension.');
 
     // Enable extension checking for text and image files.
     $this->updateFileField($field_name, $type_name, ['file_extensions' => "txt $test_file_extension"]);
diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
index e558a4b601..41f5a81e12 100644
--- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php
@@ -376,7 +376,7 @@ public function testWidgetValidation() {
     $this->drupalPostForm(NULL, $edit, t('Upload'));
 
     $error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
-    $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', ['%type' => $type]));
+    $this->assertSession()->responseContains($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', ['%type' => $type]));
 
     // Upload file with correct extension, check that error message is removed.
     $edit[$name] = \Drupal::service('file_system')->realpath($test_file_text->getFileUri());
diff --git a/core/modules/file/tests/src/Functional/FileListingTest.php b/core/modules/file/tests/src/Functional/FileListingTest.php
index 390348e0c2..7e012a3565 100644
--- a/core/modules/file/tests/src/Functional/FileListingTest.php
+++ b/core/modules/file/tests/src/Functional/FileListingTest.php
@@ -128,11 +128,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 348cee7d3a..5b82283121 100644
--- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
+++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
@@ -38,7 +38,7 @@ public function testManagedFile() {
 
           // Submit without a file.
           $this->drupalPostForm($path, [], t('Save'));
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [])]), 'Submitted without a file.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => implode(',', [])]), 'Submitted without a file.');
 
           // Submit with a file, but with an invalid form token. Ensure the file
           // was not saved.
@@ -60,11 +60,11 @@ public function testManagedFile() {
           $this->drupalPostForm($path, $edit, t('Save'));
           $last_fid = $this->getLastFileId();
           $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.');
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
 
           // Submit no new input, but with a default file.
           $this->drupalPostForm($path . '/' . $last_fid, [], t('Save'));
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Empty submission did not change an existing file.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Empty submission did not change an existing file.');
 
           // Upload, then Submit.
           $last_fid_prior = $this->getLastFileId();
@@ -74,7 +74,7 @@ public function testManagedFile() {
           $last_fid = $this->getLastFileId();
           $this->assertTrue($last_fid > $last_fid_prior, 'New file got uploaded.');
           $this->drupalPostForm(NULL, [], t('Save'));
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]), 'Submit handler has correct file info.');
 
           // Remove, then Submit.
           $remove_button_title = $multiple ? t('Remove selected') : t('Remove');
@@ -86,7 +86,7 @@ public function testManagedFile() {
           $this->drupalGet($path . '/' . $last_fid);
           $this->drupalPostForm(NULL, $remove_edit, $remove_button_title);
           $this->drupalPostForm(NULL, [], t('Save'));
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file removal was successful.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file removal was successful.');
 
           // Upload, then Remove, then Submit.
           $this->drupalGet($path);
@@ -100,7 +100,7 @@ public function testManagedFile() {
           $this->drupalPostForm(NULL, $remove_edit, $remove_button_title);
 
           $this->drupalPostForm(NULL, [], t('Save'));
-          $this->assertRaw(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file upload and removal was successful.');
+          $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => '']), 'Submission after file upload and removal was successful.');
         }
       }
     }
@@ -124,7 +124,7 @@ public function testManagedFile() {
 
     // Save the entire form.
     $this->drupalPostForm(NULL, [], t('Save'));
-    $this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', $fid_list)]), 'Two files saved into a single multiple file element.');
+    $this->assertSession()->responseContains(t('The file ids are %fids.', ['%fids' => implode(',', $fid_list)]), 'Two files saved into a single multiple file element.');
 
     // Delete only the first file.
     $edit = [
@@ -155,7 +155,7 @@ public function testManagedFileRemoved() {
     $this->drupalPostForm(NULL, $edit, t('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 b36fe78683..a0c39d0147 100644
--- a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
+++ b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
@@ -110,7 +110,7 @@ public function testSyncedFiles() {
     $this->drupalPostForm(NULL, $edit, t('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();
@@ -143,7 +143,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 72393c4d1f..d962f4e8de 100644
--- a/core/modules/file/tests/src/Functional/FilePrivateTest.php
+++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php
@@ -57,7 +57,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(), 'File reference is displayed after attaching it');
+    $this->assertSession()->responseContains($node_file->getFilename(), 'File reference is displayed after attaching it');
     // Ensure the file can be downloaded.
     $this->drupalGet(file_create_url($node_file->getFileUri()));
     $this->assertSession()->statusCodeEquals(200);
@@ -96,7 +96,7 @@ public function testPrivateFile() {
     $this->assertUrl('node/' . $new_node->id() . '/edit');
     // Check that we got the expected constraint form error.
     $constraint = new ReferenceAccessConstraint();
-    $this->assertRaw(new FormattableMarkup($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
+    $this->assertSession()->responseContains(new FormattableMarkup($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
     // Attempt to reuse the existing file when creating a new node, and confirm
     // that access is still denied.
     $edit = [];
@@ -109,7 +109,7 @@ public function testPrivateFile() {
     $new_node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->assertTrue(empty($new_node), 'Node was not created.');
     $this->assertUrl('node/add/' . $type_name);
-    $this->assertRaw(new FormattableMarkup($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
+    $this->assertSession()->responseContains(new FormattableMarkup($constraint->message, ['%type' => 'file', '%id' => $node_file->id()]));
 
     // Now make file_test_file_download() return everything.
     \Drupal::state()->set('file_test.allow_all', TRUE);
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index bd7891920b..dd77a2ecdd 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -87,7 +87,7 @@ protected function setUp(): void {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called then clean out the hook
     // counters.
@@ -116,7 +116,7 @@ public function testNormal() {
     $edit = ['files[file_test_upload][]' => $file_system->realpath($image2->uri)];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->responseContains(t('You WIN!'));
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
 
     // Check that the correct hooks were called.
@@ -142,7 +142,7 @@ public function testNormal() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->responseContains(t('You WIN!'));
     $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
   }
 
@@ -166,8 +166,8 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>';
-    $this->assertRaw($message, 'Cannot upload a disallowed extension');
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains($message, 'Cannot upload a disallowed extension');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -186,7 +186,7 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -203,7 +203,7 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -228,9 +228,9 @@ public function testHandleDangerousFile() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>';
-    $this->assertRaw($message, 'Dangerous file was renamed.');
-    $this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains($message, 'Dangerous file was renamed.');
+    $this->assertSession()->responseContains(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -244,8 +244,8 @@ public function testHandleDangerousFile() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]), 'Dangerous file was not renamed when insecure uploads is TRUE.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('File name is @filename', ['@filename' => $this->phpfile->filename]), 'Dangerous file was not renamed when insecure uploads is TRUE.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -279,9 +279,9 @@ public function testHandleFileMunge() {
 
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
-    $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('For security reasons, your upload has been renamed'), 'Found security message.');
+    $this->assertSession()->responseContains(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -298,8 +298,8 @@ public function testHandleFileMunge() {
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -317,7 +317,7 @@ public function testExistingRename() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -335,7 +335,7 @@ public function testExistingReplace() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -353,7 +353,7 @@ public function testExistingError() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Check that the no hooks were called while failing.
     $this->assertFileHooksCalled([]);
@@ -386,13 +386,13 @@ public function testDrupalMovingUploadedFileError() {
     \Drupal::state()->set('file_test.disable_error_collection', TRUE);
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Uploading failed. Now check the log.
     $this->drupalGet('admin/reports/dblog');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
+    $this->assertSession()->responseContains(t('Upload error. Could not move uploaded file @file to destination @destination.', [
       '@file' => $this->image->getFilename(),
       '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
     ]), 'Found upload error log entry.');
@@ -412,13 +412,13 @@ public function testErrorMessagesAreNotChanged() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
     $this->assertText($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()->responseContains('Number of error messages before _file_save_upload_from_form(): 1');
+    $this->assertSession()->responseContains('Number of error messages after _file_save_upload_from_form(): 1');
 
     // Test that error messages are preserved when an error occurs.
     $edit = [
@@ -428,13 +428,13 @@ public function testErrorMessagesAreNotChanged() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Ensure the expected error message is present and the counts before and
     // after calling _file_save_upload_from_form() are correct.
     $this->assertText($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()->responseContains('Number of error messages before _file_save_upload_from_form(): 1');
+    $this->assertSession()->responseContains('Number of error messages after _file_save_upload_from_form(): 1');
 
     // Test a successful upload with no messages.
     $edit = [
@@ -442,13 +442,13 @@ public function testErrorMessagesAreNotChanged() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Ensure the error message is not present and the counts before and after
     // calling _file_save_upload_from_form() are correct.
     $this->assertNoText($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()->responseContains('Number of error messages before _file_save_upload_from_form(): 0');
+    $this->assertSession()->responseContains('Number of error messages after _file_save_upload_from_form(): 0');
   }
 
   /**
@@ -476,10 +476,10 @@ public function testCombinedErrorMessages() {
     $files['files']['file_test_upload'][1] = $file_system->realpath($textfile->uri);
     $client->request($form->getMethod(), $form->getUri(), $edit, $files);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Search for combined error message followed by a formatted list of messages.
-    $this->assertRaw(t('One or more files could not be uploaded.') . '<div class="item-list">', 'Error message contains combined list of validation errors.');
+    $this->assertSession()->responseContains(t('One or more files could not be uploaded.') . '<div class="item-list">', 'Error message contains combined list of validation errors.');
   }
 
   /**
@@ -496,7 +496,7 @@ public function testUploadFieldIsHighlighted() {
     ];
     $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
     $this->assertCount(1, $this->cssSelect('input[name="files[file_test_upload][]"].error'), 'File upload field has error.');
   }
 
diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php
index c4d9ee49f3..cfae3ba56c 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php
@@ -82,7 +82,7 @@ protected function setUp(): void {
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called then clean out the hook
     // counters.
@@ -109,7 +109,7 @@ public function testNormal() {
     $edit = ['files[file_test_upload]' => \Drupal::service('file_system')->realpath($image2->uri)];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->responseContains(t('You WIN!'));
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
 
     // Check that the correct hooks were called.
@@ -135,7 +135,7 @@ public function testNormal() {
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'));
+    $this->assertSession()->responseContains(t('You WIN!'));
     $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
   }
 
@@ -162,7 +162,7 @@ public function testDuplicate() {
     // Received a 200 response for posted test file.
     $this->assertSession()->statusCodeEquals(200);
     $message = t('The file %file already exists. Enter a unique file URI.', ['%file' => $file1->getFileUri()]);
-    $this->assertRaw($message);
+    $this->assertSession()->responseContains($message);
     $max_fid_before_duplicate = $max_fid_after;
     $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
     $this->assertEqual($max_fid_before_duplicate, $max_fid_after, 'A new managed file was not created.');
@@ -186,8 +186,8 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>';
-    $this->assertRaw($message, 'Cannot upload a disallowed extension');
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains($message, 'Cannot upload a disallowed extension');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate']);
@@ -206,7 +206,7 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -223,7 +223,7 @@ public function testHandleExtension() {
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
@@ -246,10 +246,10 @@ public function testHandleDangerousFile() {
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>';
-    $this->assertRaw($message, 'Dangerous file was renamed.');
+    $this->assertSession()->responseContains($message, 'Dangerous file was renamed.');
     $this->assertSession()->pageTextContains('File name is php-2.php.txt.');
-    $this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -264,7 +264,7 @@ public function testHandleDangerousFile() {
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
     $this->assertSession()->pageTextContains('File name is php-2.php.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -296,9 +296,9 @@ public function testHandleFileMunge() {
 
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
-    $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('For security reasons, your upload has been renamed'), 'Found security message.');
+    $this->assertSession()->responseContains(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -315,8 +315,8 @@ public function testHandleFileMunge() {
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
-    $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(['validate', 'insert']);
@@ -332,7 +332,7 @@ public function testExistingRename() {
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
     $this->assertSession()->pageTextContains('File name is image-test_0.png.');
 
     // Check that the correct hooks were called.
@@ -349,7 +349,7 @@ public function testExistingReplace() {
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
     $this->assertSession()->pageTextContains('File name is image-test.png.');
 
     // Check that the correct hooks were called.
@@ -366,7 +366,7 @@ public function testExistingError() {
     ];
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Check that the no hooks were called while failing.
     $this->assertFileHooksCalled([]);
@@ -399,13 +399,13 @@ public function testDrupalMovingUploadedFileError() {
     \Drupal::state()->set('file_test.disable_error_collection', TRUE);
     $this->drupalPostForm('file-test/upload', $edit, t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
-    $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
+    $this->assertSession()->responseContains(t('Epic upload FAIL!'), 'Found the failure message.');
 
     // Uploading failed. Now check the log.
     $this->drupalGet('admin/reports/dblog');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
+    $this->assertSession()->responseContains(t('Upload error. Could not move uploaded file @file to destination @destination.', [
       '@file' => $this->image->getFilename(),
       '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
     ]), 'Found upload error log entry.');
diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
index f50049de85..7c49e07d2f 100644
--- a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
+++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php
@@ -205,7 +205,7 @@ public function testUploadingMoreFilesThenAllowed() {
       '@count' => 3,
       '%list' => 'text-2.txt',
     ];
-    $this->assertRaw(t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args));
+    $this->assertSession()->responseContains(t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args));
   }
 
   /**
diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
index 00e2c16f24..919665dfd6 100644
--- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php
@@ -181,7 +181,7 @@ public function testFormatAdmin() {
       'name' => $name,
     ];
     $this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
-    $this->assertRaw(t('Text format names must be unique. A format named %name already exists.', [
+    $this->assertSession()->responseContains(t('Text format names must be unique. A format named %name already exists.', [
       '%name' => $name,
     ]));
   }
@@ -258,7 +258,7 @@ public function testFilterAdmin() {
     $edit['filters[' . $first_filter . '][status]'] = TRUE;
     $this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
     $this->assertUrl('admin/config/content/formats');
-    $this->assertRaw(t('Added text format %format.', ['%format' => $edit['name']]), 'New filter created.');
+    $this->assertSession()->responseContains(t('Added text format %format.', ['%format' => $edit['name']]), 'New filter created.');
 
     filter_formats_reset();
     $format = FilterFormat::load($edit['format']);
@@ -271,7 +271,7 @@ public function testFilterAdmin() {
     // Disable new filter.
     $this->drupalPostForm('admin/config/content/formats/manage/' . $format->id() . '/disable', [], t('Disable'));
     $this->assertUrl('admin/config/content/formats');
-    $this->assertRaw(t('Disabled text format %format.', ['%format' => $edit['name']]), 'Format successfully disabled.');
+    $this->assertSession()->responseContains(t('Disabled text format %format.', ['%format' => $edit['name']]), 'Format successfully disabled.');
 
     // Allow authenticated users on full HTML.
     $format = FilterFormat::load($full);
@@ -280,13 +280,13 @@ public function testFilterAdmin() {
     $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
     $this->drupalPostForm('admin/config/content/formats/manage/' . $full, $edit, t('Save configuration'));
     $this->assertUrl('admin/config/content/formats/manage/' . $full);
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully updated.');
+    $this->assertSession()->responseContains(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully updated.');
 
     // Switch user.
     $this->drupalLogin($this->webUser);
 
     $this->drupalGet('node/add/page');
-    $this->assertRaw('<option value="' . $full . '">Full HTML</option>', 'Full HTML filter accessible.');
+    $this->assertSession()->responseContains('<option value="' . $full . '">Full HTML</option>', 'Full HTML filter accessible.');
 
     // Use basic HTML and see if it removes tags that are not allowed.
     $body = '<em>' . $this->randomMachineName() . '</em>';
@@ -308,7 +308,7 @@ public function testFilterAdmin() {
     $this->assertNotEmpty($node, 'Node found in database.');
 
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw($body . $extra_text, 'Filter removed invalid tag.');
+    $this->assertSession()->responseContains($body . $extra_text, 'Filter removed invalid tag.');
 
     // 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
@@ -342,7 +342,7 @@ public function testFilterAdmin() {
     $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = FALSE;
     $this->drupalPostForm('admin/config/content/formats/manage/' . $full, $edit, t('Save configuration'));
     $this->assertUrl('admin/config/content/formats/manage/' . $full);
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully reverted.');
+    $this->assertSession()->responseContains(t('The text format %format has been updated.', ['%format' => $format->label()]), 'Full HTML format successfully reverted.');
     $this->drupalGet('admin/config/content/formats/manage/' . $full);
     $this->assertFieldByName('roles[' . RoleInterface::AUTHENTICATED_ID . ']', $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'], 'Changes reverted.');
 
@@ -388,10 +388,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>');
   }
 
   /**
@@ -441,7 +441,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()->responseContains(sprintf('Disabled text format: %s.', $format_id));
 
     // Programmatically change the text format to something random so we trigger
     // the missing text format message.
@@ -456,7 +456,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()->responseContains(sprintf('Missing text format: %s.', $format_id));
   }
 
 }
diff --git a/core/modules/filter/tests/src/Functional/FilterHooksTest.php b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
index 8ed68af263..01b718cf85 100644
--- a/core/modules/filter/tests/src/Functional/FilterHooksTest.php
+++ b/core/modules/filter/tests/src/Functional/FilterHooksTest.php
@@ -46,7 +46,7 @@ public function testFilterHooks() {
     $edit['name'] = $name;
     $edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 1;
     $this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
-    $this->assertRaw(t('Added text format %format.', ['%format' => $name]));
+    $this->assertSession()->responseContains(t('Added text format %format.', ['%format' => $name]));
     $this->assertText('hook_filter_format_insert invoked.');
 
     $format_id = $edit['format'];
@@ -55,7 +55,7 @@ public function testFilterHooks() {
     $edit = [];
     $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
     $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id, $edit, t('Save configuration'));
-    $this->assertRaw(t('The text format %format has been updated.', ['%format' => $name]));
+    $this->assertSession()->responseContains(t('The text format %format has been updated.', ['%format' => $name]));
     $this->assertText('hook_filter_format_update invoked.');
 
     // Use the format created.
@@ -69,7 +69,7 @@ public function testFilterHooks() {
 
     // Disable the text format.
     $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], t('Disable'));
-    $this->assertRaw(t('Disabled text format %format.', ['%format' => $name]));
+    $this->assertSession()->responseContains(t('Disabled text format %format.', ['%format' => $name]));
     $this->assertText('hook_filter_format_disable invoked.');
   }
 
diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php
index 9345445ac9..3385759810 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(), "Found the default forum at the /forum listing");
+    $this->assertSession()->responseContains(Link::createFromRoute(t('General discussion'), 'forum.page', ['taxonomy_term' => 1])->toString(), "Found the default forum at the /forum listing");
     // Check the presence of expected cache tags.
     $this->assertCacheTag('config:forum.settings');
 
@@ -322,20 +322,20 @@ private function doAdminTests($user) {
     $this->assertLink('Add forum');
     $this->assertLink('Add container');
     $this->clickLink('edit container');
-    $this->assertRaw('Edit container', 'Followed the link to edit the container');
+    $this->assertSession()->responseContains('Edit container', 'Followed the link to edit the 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', 'Followed the link to edit the forum');
+    $this->assertSession()->responseContains('Edit forum', 'Followed the link to edit the forum');
     // Navigate back to forum structure page.
     $this->drupalGet('admin/structure/forum');
     // Create second forum in container, destined to be deleted below.
     $delete_forum = $this->createForum('forum', $this->forumContainer['tid']);
     // Save forum overview.
     $this->drupalPostForm('admin/structure/forum/', [], t('Save'));
-    $this->assertRaw(t('The configuration options have been saved.'));
+    $this->assertSession()->responseContains(t('The configuration options have been saved.'));
     // Delete this second forum.
     $this->deleteForum($delete_forum['tid']);
     // Create forum at the top (root) level.
@@ -391,7 +391,7 @@ public function editForumVocabulary() {
     // Edit the vocabulary.
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $original_vocabulary->id(), $edit, t('Save'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Updated vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary was edited');
+    $this->assertSession()->responseContains(t('Updated vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary was edited');
 
     // Grab the newly edited vocabulary.
     $current_vocabulary = Vocabulary::load($vid);
@@ -578,7 +578,7 @@ public function createForumTopic($forum, $container = FALSE) {
     $type = t('Forum topic');
     if ($container) {
       $this->assertNoText(t('@type @title has been created.', ['@type' => $type, '@title' => $title]), 'Forum topic was not created');
-      $this->assertRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]), 'Error message was shown');
+      $this->assertSession()->responseContains(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]), 'Error message was shown');
       return;
     }
     else {
@@ -597,8 +597,8 @@ public function createForumTopic($forum, $container = FALSE) {
 
     // View forum topic.
     $this->drupalGet('node/' . $node->id());
-    $this->assertRaw($title, 'Subject was found');
-    $this->assertRaw($body, 'Body was found');
+    $this->assertSession()->responseContains($title, 'Subject was found');
+    $this->assertSession()->responseContains($body, 'Body was found');
 
     return $node;
   }
@@ -645,7 +645,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) {
       '#theme' => 'breadcrumb',
       '#links' => $breadcrumb_build,
     ];
-    $this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
+    $this->assertSession()->responseContains(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
 
     // View forum edit node.
     $this->drupalGet('node/' . $node->id() . '/edit');
@@ -679,7 +679,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) {
       // Delete forum node.
       $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
       $this->assertSession()->statusCodeEquals($response);
-      $this->assertRaw(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]), 'Forum node was deleted');
+      $this->assertSession()->responseContains(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]), 'Forum node was deleted');
     }
   }
 
@@ -709,7 +709,7 @@ private function verifyForumView($forum, $parent = NULL) {
       '#theme' => 'breadcrumb',
       '#links' => $breadcrumb_build,
     ];
-    $this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
+    $this->assertSession()->responseContains(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
   }
 
   /**
diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php
index a8b3e0321d..1945d06604 100644
--- a/core/modules/help/tests/src/Functional/HelpTest.php
+++ b/core/modules/help/tests/src/Functional/HelpTest.php
@@ -69,15 +69,15 @@ public function testHelp() {
     // Verify that introductory help text exists, goes for 100% module coverage.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/help');
-    $this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
+    $this->assertSession()->responseContains(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
 
     // Verify that hook_help() section title and description appear.
-    $this->assertRaw('<h2>' . t('Module overviews') . '</h2>');
-    $this->assertRaw('<p>' . t('Module overviews are provided by modules. Overviews available for your installed modules:'), '</p>');
+    $this->assertSession()->responseContains('<h2>' . t('Module overviews') . '</h2>');
+    $this->assertSession()->responseContains('<p>' . t('Module overviews are provided by modules. Overviews available for your installed modules:'), '</p>');
 
     // Verify that an empty section is handled correctly.
-    $this->assertRaw('<h2>' . t('Empty section') . '</h2>');
-    $this->assertRaw('<p>' . t('This description should appear.'), '</p>');
+    $this->assertSession()->responseContains('<h2>' . t('Empty section') . '</h2>');
+    $this->assertSession()->responseContains('<p>' . t('This description should appear.'), '</p>');
     $this->assertText(t('There is currently nothing in this section.'));
 
     // Make sure links are properly added for modules implementing hook_help().
@@ -88,7 +88,7 @@ public function testHelp() {
     // Ensure that module which does not provide an module overview page is
     // handled correctly.
     $this->clickLink(\Drupal::moduleHandler()->getName('help_test'));
-    $this->assertRaw(t('No help is available for module %module.', ['%module' => \Drupal::moduleHandler()->getName('help_test')]));
+    $this->assertSession()->responseContains(t('No help is available for module %module.', ['%module' => \Drupal::moduleHandler()->getName('help_test')]));
 
     // Verify that the order of topics is alphabetical by displayed module
     // name, by checking the order of some modules, including some that would
diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
index 6b94ca575c..ec6a8cd935 100644
--- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
@@ -68,7 +68,7 @@ public function testNumericStyleName() {
       'label' => $style_label,
     ];
     $this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
-    $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
+    $this->assertSession()->responseContains(t('Style %name was created.', ['%name' => $style_label]));
     $options = image_style_options();
     $this->assertArrayHasKey($style_name, $options);
   }
@@ -119,7 +119,7 @@ public function testStyle() {
       'label' => $style_label,
     ];
     $this->drupalPostForm($admin_path . '/add', $edit, t('Create new style'));
-    $this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
+    $this->assertSession()->responseContains(t('Style %name was created.', ['%name' => $style_label]));
 
     // Ensure that the expected entity operations are there.
     $this->drupalGet($admin_path);
@@ -253,7 +253,7 @@ public function testStyle() {
     // Confirm that the form submission was successful.
     $this->assertSession()->statusCodeEquals(200);
     $image_crop_effect = $style->getEffect($uuids['image_crop']);
-    $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()]));
+    $this->assertSession()->responseContains(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()]));
     // Confirm that there is no longer a link to the effect.
     $this->assertNoLinkByHref($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
     // Refresh the image style information and verify that the effect was
@@ -299,7 +299,7 @@ public function testStyle() {
 
     // Confirm that the empty text is correct on the image styles page.
     $this->drupalGet($admin_path);
-    $this->assertRaw(t('There are currently no styles. <a href=":url">Add a new one</a>.', [
+    $this->assertSession()->responseContains(t('There are currently no styles. <a href=":url">Add a new one</a>.', [
       ':url' => Url::fromRoute('image.style_add')->toString(),
     ]));
 
@@ -338,7 +338,7 @@ public function testStyleReplacement() {
 
     // Test that image is displayed using newly created style.
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), new FormattableMarkup('Image displayed using style @style.', ['@style' => $style_name]));
+    $this->assertSession()->responseContains(file_url_transform_relative($style->buildUrl($original_uri)), new FormattableMarkup('Image displayed using style @style.', ['@style' => $style_name]));
 
     // Rename the style and make sure the image field is updated.
     $new_style_name = strtolower($this->randomMachineName(10));
@@ -353,7 +353,7 @@ public function testStyleReplacement() {
 
     // Reload the image style using the new name.
     $style = ImageStyle::load($new_style_name);
-    $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), 'Image displayed using style replacement style.');
+    $this->assertSession()->responseContains(file_url_transform_relative($style->buildUrl($original_uri)), 'Image displayed using style replacement style.');
 
     // Delete the style and choose a replacement style.
     $edit = [
@@ -361,11 +361,11 @@ public function testStyleReplacement() {
     ];
     $this->drupalPostForm($style_path . $new_style_name . '/delete', $edit, t('Delete'));
     $message = t('The image style %name has been deleted.', ['%name' => $new_style_label]);
-    $this->assertRaw($message);
+    $this->assertSession()->responseContains($message);
 
     $replacement_style = ImageStyle::load('thumbnail');
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw(file_url_transform_relative($replacement_style->buildUrl($original_uri)), 'Image displayed using style replacement style.');
+    $this->assertSession()->responseContains(file_url_transform_relative($replacement_style->buildUrl($original_uri)), 'Image displayed using style replacement style.');
   }
 
   /**
@@ -484,7 +484,7 @@ public function testConfigImport() {
 
     // Test that image is displayed using newly created style.
     $this->drupalGet('node/' . $nid);
-    $this->assertRaw(file_url_transform_relative($style->buildUrl($original_uri)), new FormattableMarkup('Image displayed using style @style.', ['@style' => $style_name]));
+    $this->assertSession()->responseContains(file_url_transform_relative($style->buildUrl($original_uri)), new FormattableMarkup('Image displayed using style @style.', ['@style' => $style_name]));
 
     // Copy config to sync, and delete the image style.
     $sync = $this->container->get('config.storage.sync');
@@ -511,7 +511,7 @@ public function testImageStyleAccess() {
 
     $this->drupalGet('admin/config/media/image-styles');
     $this->clickLink(t('Edit'));
-    $this->assertRaw(t('Select a new effect'));
+    $this->assertSession()->responseContains(t('Select a new effect'));
   }
 
 }
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
index 3e2bce273a..de3ee271e2 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
@@ -284,7 +284,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');
@@ -331,7 +331,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 ccd8dd21ba..24a8f3f65e 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, 'Default formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Default formatter displaying correctly on full node view.');
 
     // Test the image linked to file formatter.
     $display_options = [
@@ -143,7 +143,7 @@ public function _testImageFieldFormatters($scheme) {
     $this->assertCacheContext('url.site');
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
-    $this->assertRaw($default_output, 'Image linked to file formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Image linked to file formatter displaying correctly on full node view.');
     // Verify that the image can be downloaded.
     $this->assertEqual(file_get_contents($test_image->uri), $this->drupalGet(file_create_url($image_uri)), '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->assertCacheTag($image_style->getCacheTags()[0]);
-    $this->assertRaw($default_output, 'Image style thumbnail formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Image style thumbnail formatter displaying correctly on full node view.');
 
     if ($scheme == 'private') {
       // Log out and ensure the file cannot be accessed.
@@ -304,7 +304,7 @@ public function testImageFieldSettings() {
     ];
     $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save'));
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
-    $this->assertRaw($default_output, 'Image displayed using user supplied alt and title attributes.');
+    $this->assertSession()->responseContains($default_output, 'Image displayed using user supplied alt and title attributes.');
 
     // Verify that alt/title longer than allowed results in a validation error.
     $test_size = 2000;
@@ -314,11 +314,11 @@ public function testImageFieldSettings() {
     ];
     $this->drupalPostForm('node/' . $nid . '/edit', $edit, t('Save'));
     $schema = $field->getFieldStorageDefinition()->getSchema();
-    $this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', [
+    $this->assertSession()->responseContains(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', [
       '%max' => $schema['columns']['alt']['length'],
       '%length' => $test_size,
     ]));
-    $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', [
+    $this->assertSession()->responseContains(t('Title cannot be longer than %max characters but is currently %length characters long.', [
       '%max' => $schema['columns']['title']['length'],
       '%length' => $test_size,
     ]));
@@ -401,7 +401,7 @@ public function testImageFieldDefaultImage() {
     $this->assertCacheTag($file->getCacheTags()[0]);
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
-    $this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.');
+    $this->assertSession()->responseContains($default_output, 'Default image displayed when no user supplied image is present.');
 
     // Create a node with an image attached and ensure that the default image
     // is not displayed.
@@ -427,7 +427,7 @@ public function testImageFieldDefaultImage() {
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
     $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.');
-    $this->assertRaw($image_output, 'User supplied image is displayed.');
+    $this->assertSession()->responseContains($image_output, 'User supplied image is displayed.');
 
     // 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.
@@ -477,7 +477,7 @@ public function testImageFieldDefaultImage() {
     $this->assertCacheTag($file->getCacheTags()[0]);
     $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
     $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
-    $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.');
+    $this->assertSession()->responseContains($default_output, 'Default private image displayed when no user supplied image is present.');
   }
 
 }
diff --git a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
index e02b0ed604..59f696c9c0 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php
@@ -141,8 +141,8 @@ public function testResolution() {
       }
     }
     $this->uploadNodeImage($image_that_is_too_small, $field_names[0], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
-    $this->assertRaw(t('The image is too small. The minimum dimensions are %dimensions pixels and the image size is %widthx%height pixels.', [
+    $this->assertSession()->responseContains(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
+    $this->assertSession()->responseContains(t('The image is too small. The minimum dimensions are %dimensions pixels and the image size is %widthx%height pixels.', [
       '%dimensions' => '50x50',
       '%width' => $image_that_is_too_small_file->getWidth(),
       '%height' => $image_that_is_too_small_file->getHeight(),
@@ -150,11 +150,11 @@ public function testResolution() {
     $this->uploadNodeImage($image_that_is_too_big, $field_names[0], 'article');
     $this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'));
     $this->uploadNodeImage($image_that_is_too_small, $field_names[1], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
+    $this->assertSession()->responseContains(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
     $this->uploadNodeImage($image_that_is_too_big, $field_names[1], 'article');
     $this->assertText(t('The image was resized to fit within the maximum allowed width of 100 pixels.'));
     $this->uploadNodeImage($image_that_is_too_small, $field_names[2], 'article');
-    $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
+    $this->assertSession()->responseContains(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
     $this->uploadNodeImage($image_that_is_too_big, $field_names[2], 'article');
     $this->assertText(t('The image was resized to fit within the maximum allowed height of 100 pixels.'));
   }
diff --git a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
index 6667c9e5cf..bbeb783e12 100644
--- a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
+++ b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
@@ -125,12 +125,12 @@ public function testSyncedImages() {
     $this->drupalPostForm(NULL, $edit, t('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();
 
@@ -164,12 +164,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/image/tests/src/Functional/ImageStyleDeleteTest.php b/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
index c6eb941ea1..78a7bb84c4 100644
--- a/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
+++ b/core/modules/image/tests/src/Functional/ImageStyleDeleteTest.php
@@ -35,7 +35,7 @@ public function testDelete() {
     // Checks that the 'replacement' select element is displayed.
     $this->assertFieldByName('replacement');
     // Checks that UI messages are correct.
-    $this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->responseContains(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
     $this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
 
     // Delete 'medium' image style but replace it with 'thumbnail'. This style
@@ -58,7 +58,7 @@ public function testDelete() {
     // Checks that the 'replacement' select element is displayed.
     $this->assertFieldByName('replacement');
     // Checks that UI messages are correct.
-    $this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->responseContains(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
     $this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
 
     // Delete 'thumbnail' image style. Provide no replacement.
@@ -79,7 +79,7 @@ public function testDelete() {
     $this->assertNoFieldByName('replacement');
     // Checks that UI messages are correct.
     $this->assertNoRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
-    $this->assertRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
+    $this->assertSession()->responseContains(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
   }
 
 }
diff --git a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
index 621910a205..55f1724282 100644
--- a/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
+++ b/core/modules/language/tests/src/Functional/AdminPathEntityConverterLanguageTest.php
@@ -40,10 +40,10 @@ public function testConfigUsingCurrentLanguage() {
 
     $this->drupalGet('es/admin/language_test/entity_using_current_language/es');
     $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Spanish']));
-    $this->assertRaw(t('Loaded %label.', ['%label' => 'Español']));
+    $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Español']));
 
     $this->drupalGet('es/admin/language_test/entity_using_original_language/es');
-    $this->assertRaw(t('Loaded %label.', ['%label' => 'Spanish']));
+    $this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Spanish']));
     $this->assertNoRaw(t('Loaded %label.', ['%label' => 'Español']));
   }
 
diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
index 3d27415e1f..43197ffff1 100644
--- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php
@@ -43,7 +43,7 @@ public function testUIBrowserLanguageMappings() {
     $message = t('Are you sure you want to delete @browser_langcode?', [
       '@browser_langcode' => $browser_langcode,
     ]);
-    $this->assertRaw($message);
+    $this->assertSession()->responseContains($message);
 
     // Confirm the delete.
     $edit = [];
@@ -53,7 +53,7 @@ public function testUIBrowserLanguageMappings() {
     $t_args = [
       '%browser' => $browser_langcode,
     ];
-    $this->assertRaw(t('The mapping for the %browser browser language code has been deleted.', $t_args), 'The test browser language code has been deleted.');
+    $this->assertSession()->responseContains(t('The mapping for the %browser browser language code has been deleted.', $t_args), 'The test browser language code has been deleted.');
 
     // Check we went back to the browser negotiation mapping overview.
     $this->assertUrl(Url::fromRoute('language.negotiation_browser', [], ['absolute' => TRUE])->toString());
diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
index 91e892ebe7..7f0c498a25 100644
--- a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
@@ -121,7 +121,7 @@ public function testLanguageConfiguration() {
     // Language entity is 'en'.
     $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
     $this->rebuildContainer();
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
 
     // Ensure that French language has a weight of 1 after being created through
     // the UI.
diff --git a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
index 03dad5c233..7431d47fa8 100644
--- a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
@@ -56,12 +56,12 @@ public function testLanguageConfiguration() {
     ];
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
 
-    $this->assertRaw(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
+    $this->assertSession()->responseContains(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
       '%field' => t('Language code'),
       ':url' => 'http://www.w3.org/International/articles/language-tags/',
     ]));
 
-    $this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')]));
+    $this->assertSession()->responseContains(t('%field cannot contain any markup.', ['%field' => t('Language name')]));
     $this->assertUrl(Url::fromRoute('language.add', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.');
 
     // Test adding a custom language with a numeric region code.
@@ -73,7 +73,7 @@ public function testLanguageConfiguration() {
     ];
 
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
-    $this->assertRaw(t(
+    $this->assertSession()->responseContains(t(
       'The language %language has been created and can now be used.',
       ['%language' => $edit['label']]
     ));
@@ -89,7 +89,7 @@ public function testLanguageConfiguration() {
 
     // Add the language the first time.
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
-    $this->assertRaw(t(
+    $this->assertSession()->responseContains(t(
       'The language %language has been created and can now be used.',
       ['%language' => $edit['label']]
     ));
@@ -97,7 +97,7 @@ public function testLanguageConfiguration() {
 
     // Add the language a second time and confirm that this is not allowed.
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
-    $this->assertRaw(t(
+    $this->assertSession()->responseContains(t(
       'The language %language (%langcode) already exists.',
       ['%language' => $edit['label'], '%langcode' => $edit['langcode']]
     ));
diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php
index 67bac87846..1e1f887de8 100644
--- a/core/modules/language/tests/src/Functional/LanguageListTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageListTest.php
@@ -67,7 +67,7 @@ public function testLanguageList() {
     ];
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
     $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString());
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
     $this->assertText(t($name), 'Test language added.');
 
     $language = \Drupal::service('language_manager')->getLanguage($langcode);
@@ -100,7 +100,7 @@ public function testLanguageList() {
       'label' => $name,
     ];
     $this->drupalPostForm('admin/config/regional/language/edit/' . $langcode, $edit, t('Save language'));
-    $this->assertRaw($name, 'The language has been updated.');
+    $this->assertSession()->responseContains($name, 'The language has been updated.');
     $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $language])->toString());
 
     // Change back the default language.
@@ -118,13 +118,13 @@ public function testLanguageList() {
     // First test the 'cancel' link.
     $this->clickLink(t('Cancel'));
     $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $english])->toString());
-    $this->assertRaw($name, 'The language was not deleted.');
+    $this->assertSession()->responseContains($name, 'The language was not deleted.');
     // Delete the language for real. This a confirm form, we do not need any
     // fields changed.
     $this->drupalPostForm('admin/config/regional/language/delete/' . $langcode, [], t('Delete'));
     // We need raw here because %language and %langcode will add HTML.
     $t_args = ['%language' => $name, '%langcode' => $langcode];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
     $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $english])->toString());
     // Verify that language is no longer found.
     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
@@ -136,7 +136,7 @@ public function testLanguageList() {
     $this->rebuildContainer();
     // We need raw here because %language and %langcode will add HTML.
     $t_args = ['%language' => 'French', '%langcode' => 'fr'];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The French language has been removed.');
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', $t_args), 'The French language has been removed.');
     $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString());
     // Verify that language is no longer found.
     $this->drupalGet('admin/config/regional/language/delete/fr');
@@ -174,7 +174,7 @@ public function testLanguageList() {
     $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
     // We need raw here because %language and %langcode will add HTML.
     $t_args = ['%language' => 'English', '%langcode' => 'en'];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The English language has been removed.');
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', $t_args), 'The English language has been removed.');
     $this->rebuildContainer();
 
     // Ensure we can't delete a locked language.
diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
index 567ab2a25b..f048c6c1d1 100644
--- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
@@ -514,7 +514,7 @@ public function testLanguageDomain() {
       'domain[it]' => 'it.example.com/',
     ];
     $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
-    $this->assertRaw(t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => 'Italian']));
+    $this->assertSession()->responseContains(t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => 'Italian']));
 
     // Build the link we're going to test.
     $link = 'it.example.com' . rtrim(base_path(), '/') . '/admin';
diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
index dc5ca8e46d..ddfd5c2662 100644
--- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
@@ -53,7 +53,7 @@ protected function setUp(): void {
 
     // Check that drupalSettings contains path prefix.
     $this->drupalGet('fr/admin/config/regional/language/detection');
-    $this->assertRaw('"pathPrefix":"fr\/"', 'drupalSettings path prefix contains language code.');
+    $this->assertSession()->responseContains('"pathPrefix":"fr\/"', 'drupalSettings path prefix contains language code.');
   }
 
   /**
diff --git a/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php
index b78fe175bc..21d1117472 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->assertFieldByName("{$field_name}[0][uri]", '', 'Link URL field is displayed');
-    $this->assertRaw('placeholder="http://example.com"');
+    $this->assertSession()->responseContains('placeholder="http://example.com"');
 
     // Create a path alias.
     $this->createPathAlias('/admin', '/a/path/alias');
@@ -221,7 +221,7 @@ protected function assertValidEntries($field_name, array $valid_entries) {
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-      $this->assertRaw('"' . $string . '"');
+      $this->assertSession()->responseContains('"' . $string . '"');
     }
   }
 
@@ -294,14 +294,14 @@ public function testLinkTitle() {
       // Assert label is shown.
       $this->assertText('Read more about this entity');
       $this->assertFieldByName("{$field_name}[0][uri]", '', 'URL field found.');
-      $this->assertRaw('placeholder="http://example.com"');
+      $this->assertSession()->responseContains('placeholder="http://example.com"');
 
       if ($title_setting === DRUPAL_DISABLED) {
         $this->assertNoFieldByName("{$field_name}[0][title]", '', 'Link text field not found.');
         $this->assertNoRaw('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->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
         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 6a4227f78c..8a9afadb92 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("Formated: <a href=\"$uri\" class=\"test-link-class\">$title</a>");
+      $this->assertSession()->responseContains("Formated: <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 09459f9e8e..71f0a1e21c 100644
--- a/core/modules/locale/tests/src/Functional/LocaleContentTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleContentTest.php
@@ -88,7 +88,7 @@ public function testContentTypeLanguageConfiguration() {
       'language_configuration[language_alterable]' => TRUE,
     ];
     $this->drupalPostForm("admin/structure/types/manage/{$type2->id()}", $edit, t('Save content type'));
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type2->label()]));
+    $this->assertSession()->responseContains(t('The content type %type has been updated.', ['%type' => $type2->label()]));
     $this->drupalLogout();
     \Drupal::languageManager()->reset();
 
@@ -118,7 +118,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>', 'Correct language selected.');
+    $this->assertSession()->responseContains('<option value="' . $langcode . '" selected="selected">' . $name . '</option>', 'Correct language selected.');
     // Ensure we can change the node language.
     $edit = [
       'langcode[0][value]' => 'en',
@@ -164,7 +164,7 @@ public function testContentTypeDirLang() {
       'language_configuration[language_alterable]' => TRUE,
     ];
     $this->drupalPostForm("admin/structure/types/manage/{$type->id()}", $edit, t('Save content type'));
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => $type->label()]));
+    $this->assertSession()->responseContains(t('The content type %type has been updated.', ['%type' => $type->label()]));
     $this->drupalLogout();
 
     // Log in as web user to add new node.
diff --git a/core/modules/locale/tests/src/Functional/LocaleExportTest.php b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
index 093e2e992d..c4bef89055 100644
--- a/core/modules/locale/tests/src/Functional/LocaleExportTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleExportTest.php
@@ -64,9 +64,9 @@ public function testExportTranslation() {
     ], t('Export'));
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
+    $this->assertSession()->responseContains('# French translation of Drupal', 'Exported French translation file.');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw('msgstr "lundi"', 'French translations present in exported file.');
+    $this->assertSession()->responseContains('msgstr "lundi"', 'French translations present in exported file.');
 
     // Import some more French translations which will be marked as customized.
     $name = $file_system->tempnam('temporary://', "po2_") . '.po';
@@ -94,9 +94,9 @@ public function testExportTranslation() {
     ], t('Export'));
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal', 'Exported French translation file with only customized strings.');
+    $this->assertSession()->responseContains('# French translation of Drupal', 'Exported French translation file with only customized strings.');
     // Ensure the customized translations exist in the file.
-    $this->assertRaw('msgstr "janvier"', 'French custom translation present in exported file.');
+    $this->assertSession()->responseContains('msgstr "janvier"', 'French custom translation present in exported file.');
     // Ensure no untranslated strings exist in the file.
     $this->assertNoRaw('msgid "February"', 'Untranslated string not present in exported file.');
 
@@ -109,11 +109,11 @@ public function testExportTranslation() {
     ], t('Export'));
 
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal', 'Exported French translation file with only untranslated strings.');
+    $this->assertSession()->responseContains('# French translation of Drupal', 'Exported French translation file with only untranslated strings.');
     // Ensure no customized translations exist in the file.
     $this->assertNoRaw('msgstr "janvier"', 'French custom translation not present in exported file.');
     // Ensure the untranslated strings exist in the file, and with right quotes.
-    $this->assertRaw($this->getUntranslatedString(), 'Empty string present in exported file.');
+    $this->assertSession()->responseContains($this->getUntranslatedString(), 'Empty string present in exported file.');
   }
 
   /**
@@ -127,7 +127,7 @@ public function testExportTranslationTemplateFile() {
     // Get the translation template file.
     $this->drupalPostForm('admin/config/regional/translate/export', [], t('Export'));
     // Ensure we have a translation file.
-    $this->assertRaw('# LANGUAGE translation of PROJECT', 'Exported translation template file.');
+    $this->assertSession()->responseContains('# LANGUAGE translation of PROJECT', 'Exported translation template file.');
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
index 5ed2632e3e..feaccc3683 100644
--- a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php
@@ -77,10 +77,10 @@ public function testStandalonePoFile() {
     ]);
     $this->config('locale.settings');
     // The import should automatically create the corresponding language.
-    $this->assertRaw(t('The language %language has been created.', ['%language' => 'French']), 'The language has been automatically created.');
+    $this->assertSession()->responseContains(t('The language %language has been created.', ['%language' => 'French']), 'The language has been automatically created.');
 
     // The import should have created 8 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 8, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 8, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
 
     // This import should have saved plural forms to have 2 variants.
     $locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
@@ -95,10 +95,10 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string and rejected 2.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
 
     $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
-    $this->assertRaw($skip_message, 'Unsafe strings were skipped.');
+    $this->assertSession()->responseContains($skip_message, 'Unsafe strings were skipped.');
 
     // Repeat the process with a user that can access site reports, and this
     // time the different warnings must contain links to the log.
@@ -110,7 +110,7 @@ public function testStandalonePoFile() {
     ]);
 
     $skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
-    $this->assertRaw($skip_message, 'Unsafe strings were skipped.');
+    $this->assertSession()->responseContains($skip_message, 'Unsafe strings were skipped.');
 
     // Check empty files import with a user that cannot access site reports..
     $this->drupalLogin($this->adminUser);
@@ -119,7 +119,7 @@ public function testStandalonePoFile() {
       'langcode' => 'fr',
     ]);
     // The import should have created 0 string and rejected 0.
-    $this->assertRaw(t('One translation file could not be imported. See the log for details.'), 'The empty translation file import reported no translations imported.');
+    $this->assertSession()->responseContains(t('One translation file could not be imported. See the log for details.'), 'The empty translation file import reported no translations imported.');
 
     // Repeat the process with a user that can access site reports, and this
     // time the different warnings must contain links to the log.
@@ -129,7 +129,7 @@ public function testStandalonePoFile() {
       'langcode' => 'fr',
     ]);
     // The import should have created 0 string and rejected 0.
-    $this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]), 'The empty translation file import reported no translations imported.');
+    $this->assertSession()->responseContains(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]), 'The empty translation file import reported no translations imported.');
 
     // Try importing a .po file which doesn't exist.
     $name = $this->randomMachineName(16);
@@ -147,7 +147,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
     // Ensure string wasn't overwritten.
     $search = [
       'string' => 'Montag',
@@ -169,7 +169,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have updated 2 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The translation file was successfully imported.');
     // Ensure string was overwritten.
     $search = [
       'string' => 'Montag',
@@ -189,7 +189,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 6 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 6, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 6, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
 
     // The database should now contain 6 customized strings (two imported
     // strings are not translated).
@@ -205,7 +205,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have created 1 string.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The customized translation file was successfully imported.');
     // Ensure string wasn't overwritten.
     $search = [
       'string' => 'januari',
@@ -224,7 +224,7 @@ public function testStandalonePoFile() {
     ]);
 
     // The import should have updated 2 strings.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The customized translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]), 'The customized translation file was successfully imported.');
     // Ensure string was overwritten.
     $search = [
       'string' => 'januari',
@@ -262,7 +262,7 @@ public function testEmptyMsgstr() {
       'langcode' => $langcode,
     ]);
 
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]), 'The translation file was successfully imported.');
     $this->assertIdentical((string) t('Operations', [], ['langcode' => $langcode]), 'Műveletek', 'String imported and translated.');
 
     // Try importing a .po file.
@@ -270,7 +270,7 @@ public function testEmptyMsgstr() {
       'langcode' => $langcode,
       'overwrite_options[not_customized]' => TRUE,
     ]);
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 0, '%delete' => 1]), 'The translation file was successfully imported.');
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 0, '%delete' => 1]), 'The translation file was successfully imported.');
 
     $str = "Operations";
     $search = [
diff --git a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
index 6b41adb08b..1e55668ef3 100644
--- a/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleJavascriptTranslationTest.php
@@ -160,8 +160,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->assertTrue(strpos($content, $js_filename) < strpos($content, 'core/misc/drupal.js'), 'Translations are included before Drupal.t.');
   }
diff --git a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
index 869496ef7c..e79549a753 100644
--- a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
+++ b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
@@ -237,22 +237,22 @@ public function testPluralEditExport() {
       'langcode' => 'fr',
     ], t('Export'));
     // Ensure we have a translation file.
-    $this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
+    $this->assertSession()->responseContains('# French translation of Drupal', 'Exported French translation file.');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw("msgid \"Monday\"\nmsgstr \"lundi\"", 'French translations present in exported file.');
+    $this->assertSession()->responseContains("msgid \"Monday\"\nmsgstr \"lundi\"", 'French translations present in exported file.');
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"", 'Plural translations exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure\"\nmsgstr[1] \"@count heures\"", 'Plural translations exported properly.');
 
     // Get the Croatian translations.
     $this->drupalPostForm('admin/config/regional/translate/export', [
       'langcode' => 'hr',
     ], t('Export'));
     // Ensure we have a translation file.
-    $this->assertRaw('# Croatian translation of Drupal', 'Exported Croatian translation file.');
+    $this->assertSession()->responseContains('# Croatian translation of Drupal', 'Exported Croatian translation file.');
     // Ensure our imported translations exist in the file.
-    $this->assertRaw("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"", 'Croatian translations present in exported file.');
+    $this->assertSession()->responseContains("msgid \"Monday\"\nmsgstr \"Ponedjeljak\"", 'Croatian translations present in exported file.');
     // 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\"", 'Plural translations exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata\"\nmsgstr[2] \"@count sati\"", 'Plural translations exported properly.');
 
     // Check if the source appears on the translation page.
     $this->drupalGet('admin/config/regional/translate');
@@ -338,16 +338,16 @@ public function testPluralEditExport() {
       'langcode' => 'fr',
     ], t('Export'));
     // Check for plural export specifically.
-    $this->assertRaw("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"", 'Edited French plural translations for hours exported properly.');
-    $this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"", 'Added French plural translations for days exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count heure edited\"\nmsgstr[1] \"@count heures\"", 'Edited French plural translations for hours exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"1 jour\"\nmsgstr[1] \"@count jours\"", 'Added French plural translations for days exported properly.');
 
     // Get the Croatian translations.
     $this->drupalPostForm('admin/config/regional/translate/export', [
       'langcode' => 'hr',
     ], t('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\"", 'Edited Croatian plural translations exported properly.');
-    $this->assertRaw("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"", 'Added Croatian plural translations exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 hour\"\nmsgid_plural \"@count hours\"\nmsgstr[0] \"@count sat\"\nmsgstr[1] \"@count sata edited\"\nmsgstr[2] \"@count sati\"", 'Edited Croatian plural translations exported properly.');
+    $this->assertSession()->responseContains("msgid \"1 day\"\nmsgid_plural \"@count days\"\nmsgstr[0] \"@count dan\"\nmsgstr[1] \"@count dana\"\nmsgstr[2] \"@count dana\"", 'Added Croatian plural translations exported properly.');
   }
 
   /**
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
index d002423a05..ea7bd50a69 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', 'No pending updates.');
+    $this->assertSession()->responseContains('messages--status', 'No pending updates.');
     $this->assertNoLinkByHref('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 e7b9258b83..c9e8cb53e5 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php
@@ -68,7 +68,7 @@ public function testStringTranslation() {
     t($name, [], ['langcode' => $langcode])->render();
     // Reset locale cache.
     $this->container->get('string_translation')->reset();
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
     $this->assertText(t($name), 'Test language added.');
     $this->drupalLogout();
 
@@ -110,7 +110,7 @@ public function testStringTranslation() {
       'translation' => 'translated',
     ];
     $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
-    $this->assertRaw($translation, 'Non-English translation properly saved.');
+    $this->assertSession()->responseContains($translation, 'Non-English translation properly saved.');
 
     $search = [
       'string' => $name,
@@ -130,7 +130,7 @@ public function testStringTranslation() {
       'translation' => 'translated',
     ];
     $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
-    $this->assertRaw($translation_to_en, 'English translation properly saved.');
+    $this->assertSession()->responseContains($translation_to_en, 'English translation properly saved.');
 
     $this->assertTrue($name != $translation && t($name, [], ['langcode' => $langcode]) == $translation, 't() works for non-English.');
     // Refresh the locale() cache to get fresh data from t() below. We are in
@@ -179,7 +179,7 @@ public function testStringTranslation() {
     $this->drupalPostForm($path, [], t('Delete'));
     // We need raw here because %language and %langcode will add HTML.
     $t_args = ['%language' => $name, '%langcode' => $langcode];
-    $this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
+    $this->assertSession()->responseContains(t('The %language (%langcode) language has been removed.', $t_args), 'The test language has been removed.');
     // Reload to remove $name.
     $this->drupalGet($path);
     // Verify that language is no longer found.
@@ -201,7 +201,7 @@ public function testStringTranslation() {
       $lid => '',
     ];
     $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
-    $this->assertRaw($name, 'The strings have been saved.');
+    $this->assertSession()->responseContains($name, 'The strings have been saved.');
     $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 99114f56d5..40a3c5b74b 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
@@ -46,7 +46,7 @@ public function testInterface() {
     $this->assertNoText(t('Translation update status'), 'No status message');
 
     $this->drupalGet('admin/reports/translations');
-    $this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [':add_language' => Url::fromRoute('entity.configurable_language.collection')->toString()]), 'Language message');
+    $this->assertSession()->responseContains(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [':add_language' => Url::fromRoute('entity.configurable_language.collection')->toString()]), 'Language message');
 
     // Add German language.
     $this->addLanguage('de');
@@ -71,7 +71,7 @@ public function testInterface() {
     // Check if updates are available for German.
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Translation update status'), 'Status message');
-    $this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]), 'Updates available message');
+    $this->assertSession()->responseContains(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]), 'Updates available message');
     $this->drupalGet('admin/reports/translations');
     $this->assertText(t('Updates for: @modules', ['@modules' => 'Locale test translate']), 'Translations available');
 
@@ -85,7 +85,7 @@ public function testInterface() {
     // Check if no updates were found.
     $this->drupalGet('admin/reports/status');
     $this->assertText(t('Translation update status'), 'Status message');
-    $this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]), 'Missing translations message');
+    $this->assertSession()->responseContains(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]), 'Missing translations message');
     $this->drupalGet('admin/reports/translations');
     $this->assertText(t('Missing translations for one project'), 'No translations found');
     $release_details = new FormattableMarkup('@module (@version). @info', [
@@ -93,7 +93,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(), 'Release details');
+    $this->assertSession()->responseContains($release_details->__toString(), 'Release details');
 
     // 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 7c470056a5..70ec66cb48 100644
--- a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
@@ -121,7 +121,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>', 'German language found');
+    $this->assertSession()->responseContains('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>', 'German language found');
     $this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test', 'Updates found');
     /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
     $date_formatter = $this->container->get('date.formatter');
@@ -302,7 +302,7 @@ public function testEnableUninstallModule() {
     $this->drupalPostForm('admin/modules', $edit, t('Install'));
 
     // Check if translations have been imported.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
       ['%number' => 7, '%update' => 0, '%delete' => 0]), 'One translation file imported.');
     $this->assertTranslation('Tuesday', 'Dienstag', 'de');
 
@@ -347,7 +347,7 @@ public function testEnableLanguage() {
     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
 
     // Check if the right number of translations are added.
-    $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
+    $this->assertSession()->responseContains(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
       ['%number' => 8, '%update' => 0, '%delete' => 0]), 'One language added.');
     $this->assertTranslation('Extraday', 'extra dag', 'nl');
 
diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
index ae9ab1416a..5f9d8ea9c8 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php
@@ -177,7 +177,7 @@ public function testMediaOEmbedVideoSource() {
     // 'view media' permission.
     $this->drupalGet('media/oembed', ['query' => $query]);
     $assert_session->pageTextContains('By the power of Greyskull, 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->assertNoRaw('core/modules/media/templates/media-oembed-iframe.html.twig');
 
     // Test themes not inheriting from stable.
@@ -186,7 +186,7 @@ public function testMediaOEmbedVideoSource() {
     $this->drupalGet('media/oembed', ['query' => $query]);
     $assert_session->pageTextContains('By the power of Greyskull, Vimeo works!');
     $this->assertNoRaw('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/MenuLinkContentDeleteFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
index 3769a8dadb..929accc4ad 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php
@@ -51,7 +51,7 @@ public function testMenuLinkContentDeleteForm() {
 
     $menu_link = MenuLinkContent::load(1);
     $this->drupalGet($menu_link->toUrl('delete-form'));
-    $this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()]));
     $this->assertLink(t('Cancel'));
     // Make sure cancel link points to link edit
     $this->assertLinkByHref($menu_link->toUrl('edit-form')->toString());
@@ -64,7 +64,7 @@ public function testMenuLinkContentDeleteForm() {
     $menu = Menu::load($menu_link->getMenuName());
     $this->assertLinkByHref($menu->toUrl('edit-form')->toString());
     $this->drupalPostForm(NULL, [], t('Delete'));
-    $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()]));
+    $this->assertSession()->responseContains(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()]));
   }
 
 }
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 1e590223ad..ccd3633aff 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php
@@ -84,7 +84,7 @@ public function testMenuLinkContentForm() {
     $this->assertNotEmpty($element, 'A default menu parent was found.');
     $this->assertEqual('admin:', $element[0]->getValue(), '<Administration> menu is the parent.');
     // Test that the field description is present.
-    $this->assertRaw('The location this menu link points to.');
+    $this->assertSession()->responseContains('The location this menu link points to.');
 
     $this->drupalPostForm(
       NULL,
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 0087b79027..4c3dd96cdd 100644
--- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
+++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php
@@ -98,9 +98,9 @@ public function testTranslationLinkTheme() {
     $edit['admin_theme'] = 'seven';
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
     $this->drupalGet('admin/structure/menu/item/' . $entityId . '/edit');
-    $this->assertRaw('core/themes/seven/css/base/elements.css', 'Edit uses admin theme.');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css', 'Edit uses admin theme.');
     $this->drupalGet('admin/structure/menu/item/' . $entityId . '/edit/translations');
-    $this->assertRaw('core/themes/seven/css/base/elements.css', 'Translation uses admin theme as well.');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css', 'Translation uses admin theme as well.');
   }
 
   /**
@@ -124,7 +124,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
index 256f175775..7008885cd9 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php
@@ -121,7 +121,7 @@ public function testMenuNodeFormWidget() {
       'menu_parent' => 'main:',
     ];
     $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
-    $this->assertRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
+    $this->assertSession()->responseContains(t('The content type %name has been updated.', ['%name' => 'Basic page']));
 
     // Test that we can preview a node that will create a menu item.
     $edit = [
diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
index 55fe2f41ad..d6cd457ced 100644
--- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
+++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
@@ -180,14 +180,14 @@ public function addCustomMenuCRUD() {
 
     // Assert the new menu.
     $this->drupalGet('admin/structure/menu/manage/' . $menu_name);
-    $this->assertRaw($label, 'Custom menu was added.');
+    $this->assertSession()->responseContains($label, 'Custom menu was added.');
 
     // 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, 'Custom menu was edited.');
+    $this->assertSession()->responseContains($new_label, 'Custom menu was edited.');
   }
 
   /**
@@ -210,7 +210,7 @@ public function addCustomMenu() {
 
     // Verify that using a menu_name that is too long results in a validation
     // message.
-    $this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
+    $this->assertSession()->responseContains(t('@name cannot be longer than %max characters but is currently %length characters long.', [
       '@name' => t('Menu name'),
       '%max' => MenuStorage::MAX_ID_LENGTH,
       '%length' => mb_strlen($menu_name),
@@ -228,7 +228,7 @@ public function addCustomMenu() {
       '%length' => mb_strlen($menu_name),
     ]));
     // Verify that the confirmation message is displayed.
-    $this->assertRaw(t('Menu %label has been added.', ['%label' => $label]));
+    $this->assertSession()->responseContains(t('Menu %label has been added.', ['%label' => $label]));
     $this->drupalGet('admin/structure/menu');
     $this->assertText($label, 'Menu created');
 
@@ -256,7 +256,7 @@ public function deleteCustomMenu() {
     // Delete custom menu.
     $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", [], t('Delete'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu %title has been deleted.', ['%title' => $label]), 'Custom menu was deleted');
+    $this->assertSession()->responseContains(t('The menu %title has been deleted.', ['%title' => $label]), 'Custom menu was deleted');
     $this->assertNull(Menu::load($menu_name), 'Custom menu was deleted');
     // Test if all menu links associated with the menu were removed from
     // database.
@@ -293,7 +293,7 @@ public function doMenuTests() {
     $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
     // Test the 'Delete' operation.
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', ['%item' => $link_title]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the custom menu link %item?', ['%item' => $link_title]));
     $this->drupalPostForm(NULL, [], t('Delete'));
     $this->assertUrl(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
 
@@ -637,7 +637,7 @@ public function addInvalidMenuLink() {
         'title[0][value]' => 'title',
       ];
       $this->drupalPostForm("admin/structure/menu/manage/{$this->menu->id()}/add", $edit, t('Save'));
-      $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => $link_path]), 'Menu link was not created');
+      $this->assertSession()->responseContains(t("The path '@link_path' is inaccessible.", ['@link_path' => $link_path]), 'Menu link was not created');
     }
   }
 
@@ -777,7 +777,7 @@ public function resetMenuLink(MenuLinkInterface $menu_link, $old_weight) {
     // Reset menu link.
     $this->drupalPostForm("admin/structure/menu/link/{$menu_link->getPluginId()}/reset", [], t('Reset'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset');
+    $this->assertSession()->responseContains(t('The menu link was reset to its default settings.'), 'Menu link was reset');
 
     // Verify menu link.
     $instance = \Drupal::service('plugin.manager.menu.link')->createInstance($menu_link->getPluginId());
@@ -797,7 +797,7 @@ public function deleteMenuLink(MenuLinkContent $item) {
     // Delete menu link.
     $this->drupalPostForm("admin/structure/menu/item/$mlid/delete", [], t('Delete'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $title]), 'Menu link was deleted');
+    $this->assertSession()->responseContains(t('The menu link %title has been deleted.', ['%title' => $title]), 'Menu link was deleted');
 
     // Verify deletion.
     $this->drupalGet('');
diff --git a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
index 53ac68709c..d0a97e9d22 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php
@@ -114,7 +114,7 @@ public function testNodeAccessAdministerField() {
 
     // Confirm that the new default value appears when creating a new node.
     $this->drupalGet('node/add/page');
-    $this->assertRaw($default, 'The updated default value is displayed when creating a new node.');
+    $this->assertSession()->responseContains($default, 'The updated default value is displayed when creating a new node.');
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
index ffb2b77678..d9f9486263 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php
@@ -66,7 +66,7 @@ public function testCommentPager() {
     $this->drupalGet('node/' . $node->id());
     $this->assertText($node->label());
     $this->assertText(t('Comments'));
-    $this->assertRaw('page=1');
+    $this->assertSession()->responseContains('page=1');
     $this->assertNoRaw('page=2');
   }
 
@@ -98,7 +98,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->assertNoRaw('page=2');
   }
 
diff --git a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
index 11c646df8c..e7e2d0bd17 100644
--- a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php
@@ -76,7 +76,7 @@ public function testAssignOwnerNodeActionConfiguration() {
     $this->assertSession()->statusCodeEquals(200);
 
     // Make sure that the action was actually deleted.
-    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.');
+    $this->assertSession()->responseContains(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.');
     $this->drupalGet('admin/config/system/actions');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.');
diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
index fea180f3ae..7f9a5ef1d3 100644
--- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php
+++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php
@@ -79,7 +79,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>', 'Edit tab found and marked active.');
+    $this->assertSession()->responseContains('Edit<span class="visually-hidden">(active tab)</span>', 'Edit tab found and marked active.');
     $this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
     $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
 
@@ -131,7 +131,7 @@ public function testNodeEdit() {
     $open_details_elements = count($this->cssSelect('details[open="open"]'));
     $this->drupalPostForm(NULL, $edit, t('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->assertEqual(count($this->cssSelect('details[open="open"]')), $open_details_elements, 'Exactly one extra open &lt;details&gt; element found.');
@@ -255,7 +255,7 @@ protected function checkVariousAuthoredByValues(NodeInterface $node, $form_eleme
       $form_element_name => 'invalid-name',
     ];
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
-    $this->assertRaw(t('There are no entities matching "%name".', ['%name' => 'invalid-name']));
+    $this->assertSession()->responseContains(t('There are no entities matching "%name".', ['%name' => 'invalid-name']));
 
     // Change the authored by field to an empty string, which should assign
     // authorship to the anonymous user (uid 0).
diff --git a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
index 61c7c5caa7..f856ab8380 100644
--- a/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
+++ b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php
@@ -49,7 +49,7 @@ protected function setUp(): void {
       'language_configuration[language_alterable]' => TRUE,
     ];
     $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
+    $this->assertSession()->responseContains(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
 
     // Make node body translatable.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
@@ -96,10 +96,10 @@ public function testMultilingualNodeForm() {
 
     // Test multilingual field language fallback logic.
     $this->drupalGet("it/node/{$node->id()}");
-    $this->assertRaw($body_value, 'Body correctly displayed using Italian as requested language');
+    $this->assertSession()->responseContains($body_value, 'Body correctly displayed using Italian as requested language');
 
     $this->drupalGet("node/{$node->id()}");
-    $this->assertRaw($body_value, 'Body correctly displayed using English as requested language');
+    $this->assertSession()->responseContains($body_value, 'Body correctly displayed using English as requested language');
   }
 
   /**
diff --git a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
index b36b032735..323839dfba 100644
--- a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php
@@ -58,8 +58,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, 'Extra RSS elements appear in RSS feed.');
-    $this->assertRaw($test_ns, 'Extra namespaces appear in RSS feed.');
+    $this->assertSession()->responseContains($test_element, 'Extra RSS elements appear in RSS feed.');
+    $this->assertSession()->responseContains($test_ns, 'Extra namespaces appear in RSS feed.');
 
     // Check that content added in 'rss' view mode doesn't appear when
     // viewing node.
@@ -105,9 +105,9 @@ public function testUrlHandling() {
     ]);
 
     $this->drupalGet('rss.xml');
-    $this->assertRaw(file_create_url('public://root-relative'), 'Root-relative URL is transformed to absolute.');
-    $this->assertRaw($protocol_relative_url, 'Protocol-relative URL is left untouched.');
-    $this->assertRaw($absolute_url, 'Absolute URL is left untouched.');
+    $this->assertSession()->responseContains(file_create_url('public://root-relative'), 'Root-relative URL is transformed to absolute.');
+    $this->assertSession()->responseContains($protocol_relative_url, 'Protocol-relative URL is left untouched.');
+    $this->assertSession()->responseContains($absolute_url, 'Absolute URL is left untouched.');
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
index 5d0956b50f..75aa289a87 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
@@ -149,7 +149,7 @@ public function testRevisions() {
 
     // Confirm that revisions revert properly.
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert", [], t('Revert'));
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.',
+    $this->assertSession()->responseContains(t('@type %title has been reverted to the revision from %revision-date.',
       [
         '@type' => 'Basic page',
         '%title' => $nodes[1]->getTitle(),
@@ -176,7 +176,7 @@ public function testRevisions() {
 
     // Confirm revisions delete properly.
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], t('Delete'));
-    $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
+    $this->assertSession()->responseContains(t('Revision from %revision-date of @type %title has been deleted.',
       [
         '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
         '@type' => 'Basic page',
@@ -198,7 +198,7 @@ public function testRevisions() {
       ])
       ->execute();
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", [], t('Revert'));
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
+    $this->assertSession()->responseContains(t('@type %title has been reverted to the revision from %revision-date.', [
       '@type' => 'Basic page',
       '%title' => $nodes[2]->getTitle(),
       '%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
@@ -217,7 +217,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->assertText(end($logs));
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
index b1daab2555..48e0f237f3 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php
@@ -172,7 +172,7 @@ public function testRevisions() {
 
     // Confirm that revisions revert properly.
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert", [], t('Revert'));
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
+    $this->assertSession()->responseContains(t('@type %title has been reverted to the revision from %revision-date.', [
       '@type' => 'Basic page',
       '%title' => $nodes[1]->label(),
       '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
@@ -191,7 +191,7 @@ public function testRevisions() {
 
     // Confirm revisions delete properly.
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], t('Delete'));
-    $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', [
+    $this->assertSession()->responseContains(t('Revision from %revision-date of @type %title has been deleted.', [
       '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
       '@type' => 'Basic page',
       '%title' => $nodes[1]->label(),
@@ -210,7 +210,7 @@ public function testRevisions() {
       ])
       ->execute();
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", [], t('Revert'));
-    $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
+    $this->assertSession()->responseContains(t('@type %title has been reverted to the revision from %revision-date.', [
       '@type' => 'Basic page',
       '%title' => $nodes[2]->label(),
       '%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
index 75e2cb1e68..6e178451a9 100644
--- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
@@ -120,11 +120,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 92bf8fd126..2079171c5a 100644
--- a/core/modules/node/tests/src/Functional/NodeTitleTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTitleTest.php
@@ -98,11 +98,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>', 'Page title is equal to article\'s "title".', 'Node');
+    $this->assertSession()->responseContains('<title>' . $edge_case_title_escaped . ' | Drupal</title>', 'Page title is equal to article\'s "title".', 'Node');
 
     // 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>', 'Page title is equal to article\'s "title".', 'Node');
+    $this->assertSession()->responseContains('<title>' . $edge_case_title_escaped . ' | Drupal</title>', 'Page title is equal to article\'s "title".', 'Node');
 
   }
 
diff --git a/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
index a5302e7042..36f3041e8f 100644
--- a/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php
@@ -38,7 +38,7 @@ public function testNodeTitleXSS() {
 
     $this->drupalGet('node/' . $node->id());
     // Titles should be escaped.
-    $this->assertRaw('<title>' . Html::escape($title) . ' | Drupal</title>', 'Title is displayed when viewing a node.');
+    $this->assertSession()->responseContains('<title>' . Html::escape($title) . ' | Drupal</title>', 'Title is displayed when viewing a node.');
     $this->assertNoRaw($xss, 'Harmful tags are escaped when viewing a node.');
 
     $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 697be9a6de..a37e190c34 100644
--- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -252,7 +252,7 @@ public function testTranslationLinkTheme() {
     $edit['use_admin_theme'] = TRUE;
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
     $this->drupalGet('node/' . $article->id() . '/translations');
-    $this->assertRaw('core/themes/seven/css/base/elements.css', 'Translation uses admin theme if edit is admin.');
+    $this->assertSession()->responseContains('core/themes/seven/css/base/elements.css', 'Translation uses admin theme if edit is admin.');
 
     // Turn off admin theme for editing, assert inheritance to translations.
     $edit['use_admin_theme'] = FALSE;
@@ -466,7 +466,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php
index 3484cef5b1..a83df2f449 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php
@@ -176,7 +176,7 @@ public function testNodeTypeDeletion() {
     $node = $this->drupalCreateNode(['type' => $type->id()]);
     // Attempt to delete the content type, which should not be allowed.
     $this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', ['%type' => $type->label()]),
       'The content type will not be deleted until all nodes of that type are removed.'
     );
@@ -186,7 +186,7 @@ public function testNodeTypeDeletion() {
     $node->delete();
     // Attempt to delete the content type, which should now be allowed.
     $this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       t('Are you sure you want to delete the content type %type?', ['%type' => $type->label()]),
       'The content type is available for deletion.'
     );
@@ -256,7 +256,7 @@ public function testNodeTypeNoContentType() {
 
     // Navigate to content type administration screen
     $this->drupalGet('admin/structure/types');
-    $this->assertRaw(t('No content types available. <a href=":link">Add content type</a>.', [
+    $this->assertSession()->responseContains(t('No content types available. <a href=":link">Add content type</a>.', [
         ':link' => Url::fromRoute('node.type_add')->toString(),
       ]), 'Empty text when there are no content types in the system is correct.');
 
diff --git a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
index f9db9c2f29..078a5dfeb0 100644
--- a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php
@@ -119,14 +119,14 @@ public function testNodeTypeTranslation() {
     $this->drupalGet("$langcode/node/add/$type");
     // This is a Spanish page, so ensure the text asserted is translated in
     // Spanish and not French by adding the langcode option.
-    $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
+    $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
 
     // Check the name is translated with admin theme for editing.
     $this->drupalPostForm('admin/appearance', ['use_admin_theme' => '1'], t('Save configuration'));
     $this->drupalGet("$langcode/node/add/$type");
     // This is a Spanish page, so ensure the text asserted is translated in
     // Spanish and not French by adding the langcode option.
-    $this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
+    $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
   }
 
   /**
diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php
index 1dae8dec1c..0dad20d6a4 100644
--- a/core/modules/node/tests/src/Functional/PagePreviewTest.php
+++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php
@@ -223,7 +223,7 @@ public function testPagePreview() {
 
     $view_mode_edit = ['view_mode' => 'teaser'];
     $this->drupalPostForm('node/preview/' . $uuid . '/full', $view_mode_edit, t('Switch'));
-    $this->assertRaw('view-mode-teaser', 'View mode teaser class found.');
+    $this->assertSession()->responseContains('view-mode-teaser', 'View mode teaser class found.');
     $this->assertNoText($edit[$body_key], 'Body not displayed.');
 
     // Check that the title, body and term fields are displayed with the
@@ -271,8 +271,8 @@ public function testPagePreview() {
     $newterm2 = $this->randomMachineName(8);
     $edit[$term_key] = $this->term->getName() . ', ' . $newterm1 . ', ' . $newterm2;
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
-    $this->assertRaw('>' . $newterm1 . '<', 'First new term displayed.');
-    $this->assertRaw('>' . $newterm2 . '<', 'Second new term displayed.');
+    $this->assertSession()->responseContains('>' . $newterm1 . '<', 'First new term displayed.');
+    $this->assertSession()->responseContains('>' . $newterm2 . '<', 'Second new term displayed.');
     // The first term should be displayed as link, the others not.
     $this->assertLink($this->term->getName());
     $this->assertNoLink($newterm1);
@@ -286,9 +286,9 @@ public function testPagePreview() {
     $newterm3 = $this->randomMachineName(8);
     $edit[$term_key] = $newterm1 . ', ' . $newterm3 . ', ' . $newterm2;
     $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
-    $this->assertRaw('>' . $newterm1 . '<', 'First existing term displayed.');
-    $this->assertRaw('>' . $newterm2 . '<', 'Second existing term displayed.');
-    $this->assertRaw('>' . $newterm3 . '<', 'Third new term displayed.');
+    $this->assertSession()->responseContains('>' . $newterm1 . '<', 'First existing term displayed.');
+    $this->assertSession()->responseContains('>' . $newterm2 . '<', 'Second existing term displayed.');
+    $this->assertSession()->responseContains('>' . $newterm3 . '<', 'Third new term displayed.');
     $this->assertNoText($this->term->getName());
     $this->assertLink($newterm1);
     $this->assertLink($newterm2);
@@ -317,7 +317,7 @@ public function testPagePreview() {
     $this->assertNoRaw('edit-submit');
     $this->drupalPostForm('node/add/page', [$title_key => 'Preview'], t('Preview'));
     $this->clickLink(t('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
@@ -367,10 +367,10 @@ public function testPagePreview() {
       'title[0][value]' => $title,
       'field_test_multi[0][value]' => $example_text_1,
     ];
-    $this->assertRaw('Storage is not set');
+    $this->assertSession()->responseContains('Storage is not set');
     $this->drupalPostForm(NULL, $edit, t('Preview'));
     $this->clickLink(t('Back to content editing'));
-    $this->assertRaw('Storage is set');
+    $this->assertSession()->responseContains('Storage is set');
     $this->assertFieldByName('field_test_multi[0][value]');
     $this->drupalPostForm(NULL, [], t('Save'));
     $this->assertText('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 7c7561c337..5fe739e425 100644
--- a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php
+++ b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php
@@ -93,7 +93,7 @@ public function testNodeEditAccess() {
       'action' => 'node_unpublish_action',
     ];
     $this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items'));
-    $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [
+    $this->assertSession()->responseContains(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(),
@@ -138,7 +138,7 @@ public function testNodeEditAccess() {
     ];
     $this->drupalPostForm('test-node-bulk-form', $edit, t('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.', [
+    $this->assertSession()->responseContains(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(),
diff --git a/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php b/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php
index 4e32b723ab..7a872d74e2 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 a63ba2084e..a1e5b6afab 100644
--- a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
+++ b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php
@@ -145,8 +145,8 @@ public function testRadioButtons() {
     $this->assertNoFieldChecked('edit-card-1-0');
     $this->assertNoFieldChecked('edit-card-1-1');
     $this->assertNoFieldChecked('edit-card-1-2');
-    $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
-    $this->assertRaw('Some HTML encoded markup with &lt; &amp; &gt;');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('Some HTML encoded markup with &lt; &amp; &gt;');
 
     // Select first option.
     $edit = ['card_1' => 0];
@@ -203,7 +203,7 @@ public function testCheckBoxes() {
     $this->assertNoFieldChecked('edit-card-2-0');
     $this->assertNoFieldChecked('edit-card-2-1');
     $this->assertNoFieldChecked('edit-card-2-2');
-    $this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
 
     // Submit form: select first and third options.
     $edit = [
@@ -299,12 +299,12 @@ 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', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
 
     // Submit form: select invalid 'none' option.
     $edit = ['card_1' => '_none'];
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('@title field is required.', ['@title' => $field->getName()]), 'Cannot save a required field when selecting "none" from the select list.');
+    $this->assertSession()->responseContains(t('@title field is required.', ['@title' => $field->getName()]), 'Cannot save a required field when selecting "none" from the select list.');
 
     // Submit form: select first option.
     $edit = ['card_1' => 0];
@@ -343,9 +343,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', 'Option text was properly filtered.');
-    $this->assertRaw('More &lt;script&gt;dangerous&lt;/script&gt; markup', 'Option group text was properly filtered.');
-    $this->assertRaw('Group 1', 'Option groups are displayed.');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('More &lt;script&gt;dangerous&lt;/script&gt; markup', 'Option group text was properly filtered.');
+    $this->assertSession()->responseContains('Group 1', 'Option groups are displayed.');
 
     // Submit form: select first option.
     $edit = ['card_1' => 0];
@@ -395,7 +395,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', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
 
     // Submit form: select first and third options.
     $edit = ['card_2[]' => [0 => 0, 2 => 2]];
@@ -465,9 +465,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', 'Option text was properly filtered.');
-    $this->assertRaw('More &lt;script&gt;dangerous&lt;/script&gt; markup', 'Option group text was properly filtered.');
-    $this->assertRaw('Group 1', 'Option groups are displayed.');
+    $this->assertSession()->responseContains('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
+    $this->assertSession()->responseContains('More &lt;script&gt;dangerous&lt;/script&gt; markup', 'Option group text was properly filtered.');
+    $this->assertSession()->responseContains('Group 1', 'Option groups are displayed.');
 
     // 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 b361a21357..0b0c1b12da 100644
--- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
+++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php
@@ -134,13 +134,13 @@ public function testQueryParameterFormatRequests() {
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'HTML page was not yet cached.');
     $this->drupalGet($accept_header_cache_url);
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'HTML page was cached.');
-    $this->assertRaw('<p>oh hai this is html.</p>', 'The correct HTML response was returned.');
+    $this->assertSession()->responseContains('<p>oh hai this is html.</p>', 'The correct HTML response was returned.');
 
     $this->drupalGet($accept_header_cache_url_with_json);
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Json response was not yet cached.');
     $this->drupalGet($accept_header_cache_url_with_json);
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Json response was cached.');
-    $this->assertRaw('{"content":"oh hai this is json"}', 'The correct Json response was returned.');
+    $this->assertSession()->responseContains('{"content":"oh hai this is json"}', 'The correct Json response was returned.');
 
     // Enable REST support for nodes and hal+json.
     \Drupal::service('module_installer')->install(['node', 'rest', 'hal', 'basic_auth']);
diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php
index 99eaa4fee0..b6186b6263 100644
--- a/core/modules/path/tests/src/Functional/PathAliasTest.php
+++ b/core/modules/path/tests/src/Functional/PathAliasTest.php
@@ -135,12 +135,12 @@ public function testAdminAlias() {
     $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
 
     // Confirm no duplicate was created.
-    $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]), 'Attempt to move alias was rejected.');
+    $this->assertSession()->responseContains(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]), 'Attempt to move alias was rejected.');
 
     $edit_upper = $edit;
     $edit_upper['alias[0][value]'] = mb_strtoupper($edit['alias[0][value]']);
     $this->drupalPostForm('admin/config/search/path/add', $edit_upper, t('Save'));
-    $this->assertRaw(t('The alias %alias could not be added because it is already in use in this language with different capitalization: %stored_alias.', [
+    $this->assertSession()->responseContains(t('The alias %alias could not be added because it is already in use in this language with different capitalization: %stored_alias.', [
       '%alias' => $edit_upper['alias[0][value]'],
       '%stored_alias' => $edit['alias[0][value]'],
     ]), 'Attempt to move upper-case alias was rejected.');
@@ -148,7 +148,7 @@ public function testAdminAlias() {
     // Delete alias.
     $this->drupalGet('admin/config/search/path/edit/' . $pid);
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the URL alias %name?', ['%name' => $edit['alias[0][value]']]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the URL alias %name?', ['%name' => $edit['alias[0][value]']]));
     $this->drupalPostForm(NULL, [], t('Delete'));
 
     // Confirm that the alias no longer works.
@@ -211,7 +211,7 @@ public function testAdminAlias() {
     $edit['alias[0][value]'] = $node4_alias;
     $edit['path[0][value]'] = '/node/' . $node3->id();
     $this->drupalPostForm('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
-    $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
+    $this->assertSession()->responseContains(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
 
     // Create an alias without a starting slash.
     $node5 = $this->drupalCreateNode();
diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
index ee64685004..5577656130 100644
--- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php
@@ -194,8 +194,8 @@ public function testWithPendingRevision() {
     $this->assertNoRaw('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
@@ -336,7 +336,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 214e5b111a..11b9121b51 100644
--- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
@@ -204,7 +204,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       '#alt' => $alt,
     ];
     $default_output = str_replace("\n", NULL, $renderer->renderRoot($image));
-    $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Default formatter displaying correctly on full node view.');
 
     // Test field not being configured. This should not cause a fatal error.
     $display_options = [
@@ -290,33 +290,33 @@ 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->assertRaw('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== 1x, ' . file_url_transform_relative($thumbnail_style->buildUrl($image_uri)) . ' 1.5x');
-      $this->assertRaw('/styles/medium/');
+      $this->assertSession()->responseContains('data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== 1x, ' . file_url_transform_relative($thumbnail_style->buildUrl($image_uri)) . ' 1.5x');
+      $this->assertSession()->responseContains('/styles/medium/');
       // Assert the output of the original image.
-      $this->assertRaw(file_url_transform_relative(file_create_url($image_uri)) . ' 3x');
+      $this->assertSession()->responseContains(file_url_transform_relative(file_create_url($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->assertPattern('/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->assertRaw(file_url_transform_relative($medium_style->buildUrl($image_uri)) . ' 220w, ' . file_url_transform_relative($large_style->buildUrl($image_uri)) . ' 360w');
-      $this->assertRaw('media="(min-width: 851px)"');
+      $this->assertSession()->responseContains(file_url_transform_relative($medium_style->buildUrl($image_uri)) . ' 220w, ' . file_url_transform_relative($large_style->buildUrl($image_uri)) . ' 360w');
+      $this->assertSession()->responseContains('media="(min-width: 851px)"');
     }
-    $this->assertRaw('/styles/large/');
+    $this->assertSession()->responseContains('/styles/large/');
     $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
     $this->assertContains('config:responsive_image.styles.style_one', $cache_tags);
     if (!$empty_styles) {
       $this->assertContains('config:image.style.medium', $cache_tags);
       $this->assertContains('config:image.style.thumbnail', $cache_tags);
-      $this->assertRaw('type="image/png"');
+      $this->assertSession()->responseContains('type="image/png"');
     }
     $this->assertContains('config:image.style.large', $cache_tags);
 
@@ -331,7 +331,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, 'Image style large formatter displaying correctly on full node view.');
+    $this->assertSession()->responseContains($default_output, 'Image style large formatter displaying correctly on full node view.');
 
     if ($scheme == 'private') {
       // Log out and ensure the file cannot be accessed.
@@ -453,7 +453,7 @@ public function testResponsiveImageFieldFormattersOneSource() {
     $medium_style = ImageStyle::load('medium');
     $node = $node_storage->load($nid);
     $image_uri = File::load($node->{$field_name}->target_id)->getFileUri();
-    $this->assertRaw('<img srcset="' . file_url_transform_relative($medium_style->buildUrl($image_uri)) . ' 1x, ' . file_url_transform_relative($large_style->buildUrl($image_uri)) . ' 2x"');
+    $this->assertSession()->responseContains('<img srcset="' . file_url_transform_relative($medium_style->buildUrl($image_uri)) . ' 1x, ' . file_url_transform_relative($large_style->buildUrl($image_uri)) . ' 2x"');
   }
 
   /**
diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php
index e9f12fe583..ab6bf586b5 100644
--- a/core/modules/search/tests/src/Functional/SearchCommentTest.php
+++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php
@@ -182,7 +182,7 @@ public function testSearchResultsComment() {
     $this->drupalPostForm('search/node', $edit, t('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->assertNoRaw('<script>');
 
     // Search for the keyword near the evil script tag in the comment body.
@@ -193,7 +193,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->assertNoRaw('<script>');
 
     // Search for contents inside the evil script tag in the comment body.
diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
index cbe98db1c0..dbc3a7ab36 100644
--- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
@@ -133,7 +133,7 @@ public function testSearchModuleSettingsPage() {
     $this->drupalPostForm(NULL, $edit, t('Save search page'));
 
     // Ensure that the modifications took effect.
-    $this->assertRaw(t('The %label search page has been updated.', ['%label' => 'Dummy search type']));
+    $this->assertSession()->responseContains(t('The %label search page has been updated.', ['%label' => 'Dummy search type']));
     $this->drupalGet('admin/config/search/pages/manage/dummy_search_type');
     $this->assertSession()->elementExists('xpath', '//select[@id="edit-extra-type-settings-boost"]//option[@value="ii" and @selected="selected"]');
   }
@@ -262,7 +262,7 @@ public function testMultipleSearchPages() {
     $first['path'] = strtolower($this->randomMachineName(8));
     $this->drupalPostForm(NULL, $first, t('Save'));
     $this->assertDefaultSearch($first_id, 'The default page matches the only search page.');
-    $this->assertRaw(t('The %label search page has been added.', ['%label' => $first['label']]));
+    $this->assertSession()->responseContains(t('The %label search page has been added.', ['%label' => $first['label']]));
 
     // Attempt to add a search page with an existing path.
     $edit = [];
@@ -307,7 +307,7 @@ public function testMultipleSearchPages() {
 
     // Change the default search page.
     $this->clickLink(t('Set as default'));
-    $this->assertRaw(t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $second['label']]));
+    $this->assertSession()->responseContains(t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $second['label']]));
     $this->verifySearchPageOperations($first_id, TRUE, TRUE, TRUE, FALSE);
     $this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE);
 
@@ -326,9 +326,9 @@ public function testMultipleSearchPages() {
 
     // Test deleting.
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the search page %label?', ['%label' => $first['label']]));
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the search page %label?', ['%label' => $first['label']]));
     $this->drupalPostForm(NULL, [], t('Delete'));
-    $this->assertRaw(t('The search page %label has been deleted.', ['%label' => $first['label']]));
+    $this->assertSession()->responseContains(t('The search page %label has been deleted.', ['%label' => $first['label']]));
     $this->verifySearchPageOperations($first_id, FALSE, FALSE, FALSE, FALSE);
   }
 
diff --git a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
index 5b3daa61ba..3b9cb5e368 100644
--- a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
@@ -65,7 +65,7 @@ public function testSearchKeywordsConditions() {
     $keys = 'moving drop ' . $this->randomMachineName();
     $this->drupalGet("search/dummy_path", ['query' => ['keys' => 'bike', 'search_conditions' => $keys]]);
     $this->assertText("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 dffb3061c0..c128ed4583 100644
--- a/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNodeDiacriticsTest.php
@@ -56,27 +56,27 @@ public function testPhraseSearchPunctuation() {
 
     $edit = ['keys' => 'meklet'];
     $this->drupalPostForm('search/node', $edit, t('Search'));
-    $this->assertRaw('<strong>meklēt</strong>');
+    $this->assertSession()->responseContains('<strong>meklēt</strong>');
 
     $edit = ['keys' => 'meklēt'];
     $this->drupalPostForm('search/node', $edit, t('Search'));
-    $this->assertRaw('<strong>meklēt</strong>');
+    $this->assertSession()->responseContains('<strong>meklēt</strong>');
 
     $edit = ['keys' => 'cómmīŦŧęđ BɆĬŇĜ påŔťıçȉpǎǹţș'];
     $this->drupalPostForm('search/node', $edit, t('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->drupalPostForm('search/node', $edit, t('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->drupalPostForm('search/node', $edit, t('Search'));
-    $this->assertRaw('<strong>Enricþment</strong>');
+    $this->assertSession()->responseContains('<strong>Enricþment</strong>');
 
     $edit = ['keys' => 'Enritchment'];
     $this->drupalPostForm('search/node', $edit, t('Search'));
@@ -84,7 +84,7 @@ public function testPhraseSearchPunctuation() {
 
     $edit = ['keys' => 'æll'];
     $this->drupalPostForm('search/node', $edit, t('Search'));
-    $this->assertRaw('<strong>æll</strong>');
+    $this->assertSession()->responseContains('<strong>æll</strong>');
 
     $edit = ['keys' => 'all'];
     $this->drupalPostForm('search/node', $edit, t('Search'));
diff --git a/core/modules/search/tests/src/Functional/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
index 2b97a66521..0867d71463 100644
--- a/core/modules/search/tests/src/Functional/SearchPageTextTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
@@ -129,7 +129,7 @@ public function testSearchText() {
     }
     $edit['keys'] = implode(' ', $keys);
     $this->drupalPostForm('search/node', $edit, t('Search'));
-    $this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $limit]));
+    $this->assertSession()->responseContains(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $limit]));
 
     // Test that a search on Node or User with no keywords entered generates
     // the "Please enter some keywords" message.
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
index 2a30d9be5b..b4eea057fa 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()->responseContains('The location this shortcut points to.');
 
     // Check that each new shortcut links where it should.
     foreach ($test_cases as $test_path) {
@@ -114,7 +114,7 @@ public function testShortcutLinkAdd() {
     ];
     $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin']));
+    $this->assertSession()->responseContains(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin']));
 
     $form_data = [
       'title[0][value]' => $title,
@@ -216,10 +216,10 @@ public function testShortcutQuickLink() {
     // 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);
+    $this->assertSession()->responseContains($page_title);
     // Add shortcut to this page.
     $this->clickLink('Add to Default shortcuts');
-    $this->assertRaw(new FormattableMarkup('Added a shortcut for %title.', [
+    $this->assertSession()->responseContains(new FormattableMarkup('Added a shortcut for %title.', [
       '%title' => trim(strip_tags($page_title)),
     ]));
 
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
index 6576451911..29a311141c 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
@@ -94,7 +94,7 @@ public function testShortcutSetEdit() {
     }
 
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('The shortcut set has been updated.'));
+    $this->assertSession()->responseContains(t('The shortcut set has been updated.'));
 
     \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache();
     // Check to ensure that the shortcut weights have changed and that
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
index 24f41259f1..410b34c40f 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php
@@ -110,7 +110,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
index 719bc507be..12deb09eda 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', 'Statistics library is available');
+    $this->assertSession()->responseContains('core/modules/statistics/statistics.js', 'Statistics library is available');
   }
 
 }
diff --git a/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php b/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php
index 0b80251d6c..79788c4335 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(), 'Found link to visited node.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl($node->label(), $node->toUrl('canonical'))->toString(), 'Found link to visited node.');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php
index d63aa5acb9..0ff4d37484 100644
--- a/core/modules/system/tests/src/Functional/Batch/PageTest.php
+++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php
@@ -76,12 +76,12 @@ public function testBatchProgressMessages() {
     // Go to the initial step only.
     $this->maximumMetaRefreshCount = 0;
     $this->drupalGet('batch-test/test-title');
-    $this->assertRaw('<div class="progress__description">Initializing.<br />&nbsp;</div>', 'Initial progress message appears correctly.');
+    $this->assertSession()->responseContains('<div class="progress__description">Initializing.<br />&nbsp;</div>', 'Initial progress message appears correctly.');
     $this->assertNoRaw('&amp;nbsp;', 'Initial progress message is not double escaped.');
     // Now also go to the next step.
     $this->maximumMetaRefreshCount = 1;
     $this->drupalGet('batch-test/test-title');
-    $this->assertRaw('<div class="progress__description">Completed 1 of 1.</div>', 'Progress message for second step appears correctly.');
+    $this->assertSession()->responseContains('<div class="progress__description">Completed 1 of 1.</div>', 'Progress message for second step appears correctly.');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
index be691a78a1..f80cfc81f2 100644
--- a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
+++ b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php
@@ -32,16 +32,16 @@ public function testDrupalMessengerService() {
     // then removes the first before it is displayed.
     $this->drupalGet(Url::fromRoute('system_test.messenger_service'));
     $this->assertNoText('First message (removed).');
-    $this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
+    $this->assertSession()->responseContains(t('Second message with <em>markup!</em> (not removed).'));
 
     // Ensure duplicate messages are handled as expected.
     $this->assertUniqueText('Non Duplicated message');
     $this->assertNoUniqueText('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->assertUniqueText('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->assertUniqueText('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 f2cdcf24d9..c663122e95 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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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 a31d2cc5b0..02f1e8ee4f 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()->responseContains('Hello world!');
     $this->assertCacheTag('foo');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->responseContains('Hello world!');
     $this->assertCacheTag('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()->responseContains('Hello world!');
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.ajax_response.early'));
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('Hello world!');
+    $this->assertSession()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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()->responseContains('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 a97ee330a5..55d5a2dd5d 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', 'Item 50 is shown.');
+    $this->assertSession()->responseContains('Test entity 50', 'Item 50 is shown.');
     $this->assertNoRaw('Test entity 51', 'Item 51 is on the next page.');
 
     // Browse to the next page.
     $this->clickLink(t('Page 2'));
     $this->assertNoRaw('Test entity 50', 'Test entity 50 is on the previous page.');
-    $this->assertRaw('Test entity 51', 'Test entity 51 is shown.');
+    $this->assertSession()->responseContains('Test entity 51', 'Test entity 51 is shown.');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
index 11306c3fa7..ef135bf44c 100644
--- a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php
@@ -83,7 +83,7 @@ public function testEntityFormLanguage() {
     $this->drupalGet('admin/structure/types/manage/page');
     $edit = ['language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED];
     $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
-    $this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
+    $this->assertSession()->responseContains(t('The content type %type has been updated.', ['%type' => 'Basic page']), 'Basic page content type has been updated.');
 
     // Create a node with language.
     $edit = [];
diff --git a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
index 79be1dad53..7764263446 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()->responseContains($entity->label());
+      $this->assertSession()->responseContains($get_label_markup($entity->label()));
+      $this->assertSession()->responseContains('full');
 
       $this->drupalGet('entity_test_converter/' . $entity->id());
-      $this->assertRaw($entity->label());
-      $this->assertRaw('full');
+      $this->assertSession()->responseContains($entity->label());
+      $this->assertSession()->responseContains('full');
 
       $this->drupalGet('entity_test_no_view_mode/' . $entity->id());
-      $this->assertRaw($entity->label());
-      $this->assertRaw('full');
+      $this->assertSession()->responseContains($entity->label());
+      $this->assertSession()->responseContains('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()->responseContains($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 75b6c8a6f7..cfb1e22e56 100644
--- a/core/modules/system/tests/src/Functional/Form/ElementTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php
@@ -64,10 +64,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');
@@ -213,7 +213,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');
 
     $result = $this->xpath('//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
     $this->assertCount(1, $result, 'Ensure that the user does have access to the autocompletion');
diff --git a/core/modules/system/tests/src/Functional/Form/EmailTest.php b/core/modules/system/tests/src/Functional/Form/EmailTest.php
index a19e6f9ee9..010d951355 100644
--- a/core/modules/system/tests/src/Functional/Form/EmailTest.php
+++ b/core/modules/system/tests/src/Functional/Form/EmailTest.php
@@ -32,8 +32,8 @@ public function testFormEmail() {
     $edit['email'] = 'invalid';
     $edit['email_required'] = ' ';
     $this->drupalPostForm('form-test/email', $edit, 'Submit');
-    $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
-    $this->assertRaw(t('@name field is required.', ['@name' => 'Address']));
+    $this->assertSession()->responseContains(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => 'Address']));
 
     $edit = [];
     $edit['email_required'] = '  foo.bar@example.com ';
diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php
index bf5fb27646..2ccc9107c7 100644
--- a/core/modules/system/tests/src/Functional/Form/FormTest.php
+++ b/core/modules/system/tests/src/Functional/Form/FormTest.php
@@ -233,7 +233,7 @@ public function testRequiredCheckboxesRadio() {
     ];
     $this->drupalPostForm(NULL, $edit, 'Submit');
     $this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed when all required fields are filled.');
-    $this->assertRaw("The form_test_validate_required_form form was submitted successfully.", 'Validation form submitted successfully.');
+    $this->assertSession()->responseContains("The form_test_validate_required_form form was submitted successfully.", 'Validation form submitted successfully.');
   }
 
   /**
@@ -350,7 +350,7 @@ public function testRequiredTextfieldNoTitle() {
     ];
     $this->drupalPostForm(NULL, $edit, 'Submit');
     $this->assertNoFieldByXpath('//input[contains(@class, "error")]', FALSE, 'No error input form element class found.');
-    $this->assertRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
+    $this->assertSession()->responseContains("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
   }
 
   /**
@@ -362,7 +362,7 @@ public function testCheckboxProcessing() {
     // First, try to submit without the required checkbox.
     $edit = [];
     $this->drupalPostForm('form-test/checkbox', $edit, t('Submit'));
-    $this->assertRaw(t('@name field is required.', ['@name' => 'required_checkbox']), 'A required checkbox is actually mandatory');
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => 'required_checkbox']), 'A required checkbox is actually mandatory');
 
     // Now try to submit the form correctly.
     $this->drupalPostForm(NULL, ['required_checkbox' => 1], t('Submit'));
@@ -644,7 +644,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->assertNoRaw(new FormattableMarkup($message, $placeholders));
@@ -701,7 +701,7 @@ public function testColorValidation() {
         'color' => $input,
       ];
       $this->drupalPostForm('form-test/color', $edit, 'Submit');
-      $this->assertRaw(t('%name must be a valid color.', ['%name' => 'Color']));
+      $this->assertSession()->responseContains(t('%name must be a valid color.', ['%name' => 'Color']));
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
index e3d55f8fcf..849c48ddbc 100644
--- a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
+++ b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php
@@ -57,7 +57,7 @@ public function testFormStateValuesCleanAdvanced() {
 
     // Expecting a 200 HTTP code.
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('You WIN!'), 'Found the success message.');
+    $this->assertSession()->responseContains(t('You WIN!'), 'Found the success message.');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Form/UrlTest.php b/core/modules/system/tests/src/Functional/Form/UrlTest.php
index 0e99a72559..fb967dcdf1 100644
--- a/core/modules/system/tests/src/Functional/Form/UrlTest.php
+++ b/core/modules/system/tests/src/Functional/Form/UrlTest.php
@@ -34,8 +34,8 @@ public function testFormUrl() {
     $edit['url'] = 'http://';
     $edit['url_required'] = ' ';
     $this->drupalPostForm('form-test/url', $edit, 'Submit');
-    $this->assertRaw(t('The URL %url is not valid.', ['%url' => 'http://']));
-    $this->assertRaw(t('@name field is required.', ['@name' => 'Required URL']));
+    $this->assertSession()->responseContains(t('The URL %url is not valid.', ['%url' => 'http://']));
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => 'Required URL']));
 
     $edit = [];
     $edit['url'] = "\n";
diff --git a/core/modules/system/tests/src/Functional/Form/ValidationTest.php b/core/modules/system/tests/src/Functional/Form/ValidationTest.php
index 3ae3ffee1a..84e3fa04fb 100644
--- a/core/modules/system/tests/src/Functional/Form/ValidationTest.php
+++ b/core/modules/system/tests/src/Functional/Form/ValidationTest.php
@@ -160,7 +160,7 @@ public function testPatternValidation() {
       'tel' => 'valid',
     ];
     $this->drupalPostForm('form-test/pattern', $edit, 'Submit');
-    $this->assertRaw($textfield_error);
+    $this->assertSession()->responseContains($textfield_error);
     $this->assertNoRaw($tel_error);
     $this->assertNoRaw($password_error);
 
@@ -172,7 +172,7 @@ public function testPatternValidation() {
     ];
     $this->drupalPostForm('form-test/pattern', $edit, 'Submit');
     $this->assertNoRaw($textfield_error);
-    $this->assertRaw($tel_error);
+    $this->assertSession()->responseContains($tel_error);
     $this->assertNoRaw($password_error);
 
     // Non required fields are not validated if empty.
@@ -192,7 +192,7 @@ public function testPatternValidation() {
     $this->drupalPostForm('form-test/pattern', $edit, 'Submit');
     $this->assertNoRaw($textfield_error);
     $this->assertNoRaw($tel_error);
-    $this->assertRaw($password_error);
+    $this->assertSession()->responseContains($password_error);
 
     // The pattern attribute overrides #pattern and is not validated on the
     // server side.
diff --git a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
index 1c148f8d01..60818e501c 100644
--- a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
@@ -379,7 +379,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->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 47077f1d7e..8d6cec0b7c 100644
--- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
+++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
@@ -200,7 +200,7 @@ protected function doTestExoticPath() {
       // Characters from various non-ASCII alphabets.
       "éøïвβ中國書۞";
     $this->drupalGet($path);
-    $this->assertRaw('This is the menuTestCallback content.');
+    $this->assertSession()->responseContains('This is the menuTestCallback content.');
     $this->assertNoText(t('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->assertText('Active theme: seven. Actual theme: seven.', 'The administrative theme can be correctly set in a theme negotiation.');
-    $this->assertRaw('seven/css/base/elements.css', "The administrative theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('seven/css/base/elements.css', "The administrative theme's CSS appears on the page.");
   }
 
   /**
@@ -282,14 +282,14 @@ protected function doTestThemeCallbackMaintenanceMode() {
     // For a regular user, the fact that the site is in maintenance mode means
     // we expect the theme callback system to be bypassed entirely.
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
-    $this->assertRaw('bartik/css/base/elements.css', "The maintenance theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('bartik/css/base/elements.css', "The maintenance theme's CSS appears on the page.");
 
     // An administrator, however, should continue to see the requested theme.
     $admin_user = $this->drupalCreateUser(['access site in maintenance mode']);
     $this->drupalLogin($admin_user);
     $this->drupalGet('menu-test/theme-callback/use-admin-theme');
     $this->assertText('Active theme: seven. Actual theme: seven.', 'The theme negotiation system is correctly triggered for an administrator when the site is in maintenance mode.');
-    $this->assertRaw('seven/css/base/elements.css', "The administrative theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('seven/css/base/elements.css', "The administrative theme's CSS appears on the page.");
 
     $this->container->get('state')->set('system.maintenance_mode', FALSE);
   }
@@ -301,7 +301,7 @@ protected function doTestThemeCallbackOptionalTheme() {
     // Request a theme that is not installed.
     $this->drupalGet('menu-test/theme-callback/use-test-theme');
     $this->assertText('Active theme: bartik. Actual theme: bartik.', 'The theme negotiation system falls back on the default theme when a theme that is not installed is requested.');
-    $this->assertRaw('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
 
     // Now install the theme and request it again.
     /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
@@ -310,7 +310,7 @@ protected function doTestThemeCallbackOptionalTheme() {
 
     $this->drupalGet('menu-test/theme-callback/use-test-theme');
     $this->assertText('Active theme: test_theme. Actual theme: test_theme.', 'The theme negotiation system uses an optional theme once it has been installed.');
-    $this->assertRaw('test_theme/kitten.css', "The optional theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('test_theme/kitten.css', "The optional theme's CSS appears on the page.");
 
     $theme_installer->uninstall(['test_theme']);
   }
@@ -321,7 +321,7 @@ protected function doTestThemeCallbackOptionalTheme() {
   protected function doTestThemeCallbackFakeTheme() {
     $this->drupalGet('menu-test/theme-callback/use-fake-theme');
     $this->assertText('Active theme: bartik. Actual theme: bartik.', 'The theme negotiation system falls back on the default theme when a theme that does not exist is requested.');
-    $this->assertRaw('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
   }
 
   /**
@@ -330,7 +330,7 @@ protected function doTestThemeCallbackFakeTheme() {
   protected function doTestThemeCallbackNoThemeRequested() {
     $this->drupalGet('menu-test/theme-callback/no-theme-requested');
     $this->assertText('Active theme: bartik. Actual theme: bartik.', 'The theme negotiation system falls back on the default theme when no theme is requested.');
-    $this->assertRaw('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
+    $this->assertSession()->responseContains('bartik/css/base/elements.css', "The default theme's CSS appears on the page.");
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
index b8022c8b88..8b8f1570b8 100644
--- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php
+++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php
@@ -63,7 +63,7 @@ public function testMissingModules() {
     // Test that the system_dependencies_test module is marked
     // as missing a dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]), 'A module with missing dependencies is marked as such.');
+    $this->assertSession()->responseContains(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]), 'A module with missing dependencies is marked as such.');
     $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
     $this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
   }
@@ -75,7 +75,7 @@ public function testIncompatibleModuleVersionDependency() {
     // Test that the system_incompatible_module_version_dependencies_test is
     // marked as having an incompatible dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
+    $this->assertSession()->responseContains(t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
       '@module' => 'System incompatible module version test (>2.0)',
       '@version' => '1.0',
     ]), 'A module that depends on an incompatible version of a module is marked as such.');
@@ -90,7 +90,7 @@ public function testIncompatibleCoreVersionDependency() {
     // Test that the system_incompatible_core_version_dependencies_test is
     // marked as having an incompatible dependency.
     $this->drupalGet('admin/modules');
-    $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
+    $this->assertSession()->responseContains(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
       '@module' => 'System core incompatible semver test',
     ]), 'A module that depends on a module with an incompatible core version is marked as such.');
     $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
@@ -102,7 +102,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() . '.', 'User is informed when the PHP dependency requirement of a module is not met.');
+    $this->assertSession()->responseContains('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.', 'User is informed when the PHP dependency requirement of a module is not met.');
     $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_php_version_test][enable]"]');
     $this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
   }
diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php
index 3c5e9fb359..9f6451b3c1 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->assertText(\Drupal::translation()->translate('The following reason prevents Node from being uninstalled:'));
     $this->assertText(\Drupal::translation()->translate('There is content for the entity type: Content'));
@@ -112,7 +112,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 696acc16cd..f4d7d42d18 100644
--- a/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
+++ b/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
@@ -36,17 +36,17 @@ 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");
-    $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: $foo", 'user and node upcast by entity name');
+    $this->assertSession()->responseContains("user: {$user->label()}, node: {$node->label()}, foo: $foo", 'user and node upcast by entity name');
 
     // 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());
-    $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}", 'foo converted to user as well');
+    $this->assertSession()->responseContains("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}", 'foo converted to user as well');
 
     // 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");
-    $this->assertRaw("user: {$node->label()}, node: {$node->label()}, foo: $foo", 'user is upcast to node (rather than to user)');
+    $this->assertSession()->responseContains("user: {$node->label()}, node: {$node->label()}, foo: $foo", 'user is upcast to node (rather than to user)');
   }
 
   /**
@@ -58,7 +58,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()->responseContains("Setting '" . $parent->getTitle() . "' as parent of '" . $node->getTitle() . "'.");
   }
 
   /**
@@ -79,9 +79,9 @@ public function testEntityLanguage() {
     $translation->setTitle('Deutscher Titel')->save();
 
     $this->drupalGet("/paramconverter_test/node/" . $node->id() . "/test_language");
-    $this->assertRaw("English label");
+    $this->assertSession()->responseContains("English label");
     $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", ['language' => $language]);
-    $this->assertRaw("Deutscher Titel");
+    $this->assertSession()->responseContains("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 41f8586155..7bb6173588 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()->responseContains('A very important, required value.');
+    $this->assertSession()->responseContains('Explicitly passed in context.');
     $this->assertCacheTag('custom_cache_tag');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php b/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
index 97015201e4..29572ccf08 100644
--- a/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
+++ b/core/modules/system/tests/src/Functional/Render/RenderArrayNonHtmlSubscriberTest.php
@@ -33,7 +33,7 @@ public function testResponses() {
 
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Controller response successfully rendered.'));
+    $this->assertSession()->responseContains(t('Controller response successfully rendered.'));
 
     // Test that correct response code is returned for any non-HTML format.
     foreach (['json', 'hal+json', 'xml', 'foo'] as $format) {
@@ -53,7 +53,7 @@ public function testResponses() {
 
     $this->drupalGet($url);
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw(t('Raw controller response.'));
+    $this->assertSession()->responseContains(t('Raw controller response.'));
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php b/core/modules/system/tests/src/Functional/Render/UrlBubbleableMetadataBubblingTest.php
index ad2f9774fe..6d792472ff 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 ebf5b3ac9e..6a1b442fa3 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->assertNoRaw('Access denied');
-    $this->assertRaw('test7text', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('test7text', 'The correct string was returned because the route was successful.');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php
index b97ab7787f..ef6da00b14 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', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('test1', 'The correct string was returned because the route was successful.');
     $session = $this->getSession();
     // Check expected headers from FinishResponseSubscriber.
     $headers = $session->getResponseHeaders();
@@ -49,14 +49,14 @@ public function testFinishResponseSubscriber() {
     $this->assertNull($this->drupalGetHeader('Vary'), 'Vary header is not set.');
 
     $this->drupalGet('router_test/test2');
-    $this->assertRaw('test2', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('test2', 'The correct string was returned because the route was successful.');
     // Check expected headers from FinishResponseSubscriber.
     $headers = $session->getResponseHeaders();
     $this->assertEqual($headers['X-Drupal-Cache-Contexts'], [implode(' ', $expected_cache_contexts)]);
     $this->assertEqual($headers['X-Drupal-Cache-Tags'], ['config:user.role.anonymous http_response rendered']);
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>', 'Page markup was found.');
+    $this->assertSession()->responseContains('</html>', 'Page markup was found.');
     // 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', 'There was no double-page effect from a misrendered subrequest.');
@@ -119,22 +119,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');
   }
 
   /**
@@ -146,12 +146,12 @@ public function testControllerPlaceholders() {
     foreach ($values as $value) {
       $this->drupalGet('router_test/test3/' . $value);
       $this->assertSession()->statusCodeEquals(200);
-      $this->assertRaw($value, 'The correct string was returned because the route was successful.');
+      $this->assertSession()->responseContains($value, 'The correct string was returned because the route was successful.');
     }
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>', 'Page markup was found.');
+    $this->assertSession()->responseContains('</html>', 'Page markup was found.');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -164,11 +164,11 @@ public function testControllerPlaceholders() {
   public function testControllerPlaceholdersDefaultValues() {
     $this->drupalGet('router_test/test4');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('narf', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('narf', 'The correct string was returned because the route was successful.');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>', 'Page markup was found.');
+    $this->assertSession()->responseContains('</html>', 'Page markup was found.');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -181,11 +181,11 @@ public function testControllerPlaceholdersDefaultValues() {
   public function testControllerPlaceholdersDefaultValuesProvided() {
     $this->drupalGet('router_test/test4/barf');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('barf', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('barf', 'The correct string was returned because the route was successful.');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>', 'Page markup was found.');
+    $this->assertSession()->responseContains('</html>', 'Page markup was found.');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style.  This test verifies that is not happening.
@@ -201,7 +201,7 @@ public function testDynamicRoutes() {
     // Test the altered route.
     $this->drupalGet('router_test/test6');
     $this->assertSession()->statusCodeEquals(200);
-    $this->assertRaw('test5', 'The correct string was returned because the route was successful.');
+    $this->assertSession()->responseContains('test5', 'The correct string was returned because the route was successful.');
   }
 
   /**
@@ -210,11 +210,11 @@ public function testDynamicRoutes() {
   public function testControllerResolutionPage() {
     $this->drupalGet('/router_test/test10');
 
-    $this->assertRaw('abcde', 'Correct body was found.');
+    $this->assertSession()->responseContains('abcde', 'Correct body was found.');
 
     // Confirm that the page wrapping is being added, so we're not getting a
     // raw body returned.
-    $this->assertRaw('</html>', 'Page markup was found.');
+    $this->assertSession()->responseContains('</html>', 'Page markup was found.');
 
     // In some instances, the subrequest handling may get confused and render
     // a page inception style. This test verifies that is not happening.
@@ -293,7 +293,7 @@ public function testControllerResolutionAjax() {
 
     $this->assertEqual($this->drupalGetHeader('Content-Type'), 'application/json', 'Correct mime content type was returned');
 
-    $this->assertRaw('abcde', 'Correct body was found.');
+    $this->assertSession()->responseContains('abcde', 'Correct body was found.');
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php
index 8388ad5a91..9e2c6ada47 100644
--- a/core/modules/system/tests/src/Functional/Session/SessionTest.php
+++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php
@@ -289,7 +289,7 @@ public function testEmptySessionID() {
     // from persisting.
     $this->mink->resetSessions();
     $this->drupalGet('session-test/id-from-cookie');
-    $this->assertRaw("session_id:\n", 'Session ID is blank as sent from cookie header.');
+    $this->assertSession()->responseContains("session_id:\n", 'Session ID is blank as sent from cookie header.');
     // 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 79146584be..7fdfe02e9a 100644
--- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
+++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
@@ -66,7 +66,7 @@ public function testAccessDenied() {
       'site_403' => 'user/' . $this->adminUser->id(),
     ];
     $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_403']]));
+    $this->assertSession()->responseContains(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_403']]));
 
     // 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 d17e537b67..fbda9b7ec6 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, 'Fingerprinting meta tag generated correctly.', 'System');
+    $this->assertSession()->responseContains($string, 'Fingerprinting meta tag generated correctly.', 'System');
   }
 
 }
diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
index 73df393429..eef8c86f10 100644
--- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php
+++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php
@@ -130,7 +130,7 @@ public function testDateFormatConfiguration() {
     $this->clickLink(t('Delete'));
     $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', [], t('Delete'));
     $this->assertUrl(Url::fromRoute('entity.date_format.collection', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.');
-    $this->assertRaw(t('The date format %format has been deleted.', ['%format' => $name]), 'Custom date format removed.');
+    $this->assertSession()->responseContains(t('The date format %format has been deleted.', ['%format' => $name]), 'Custom date format removed.');
 
     // Make sure the date does not exist in config.
     $date_format = DateFormat::load($date_format_id);
diff --git a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
index 044715b69d..3a311acc71 100644
--- a/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
+++ b/core/modules/system/tests/src/Functional/System/DefaultMobileMetaTagsTest.php
@@ -37,7 +37,7 @@ protected function setUp(): void {
   public function testDefaultMetaTagsExist() {
     $this->drupalGet('');
     foreach ($this->defaultMetaTags as $name => $metatag) {
-      $this->assertRaw($metatag, new FormattableMarkup('Default Mobile meta tag "@name" displayed properly.', ['@name' => $name]), 'System');
+      $this->assertSession()->responseContains($metatag, new FormattableMarkup('Default Mobile meta tag "@name" displayed properly.', ['@name' => $name]), 'System');
     }
   }
 
diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
index a5b9496ad1..6088ebd1f2 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">', 'Found pre element with backtrace class.');
+    $this->assertSession()->responseContains('<pre class="backtrace">', 'Found pre element with backtrace class.');
     // Ensure we are escaping but not double escaping.
-    $this->assertRaw('&amp;');
+    $this->assertSession()->responseContains('&amp;');
     $this->assertNoRaw('&amp;amp;');
 
     // Set error reporting to display verbose notices.
@@ -129,7 +129,7 @@ public function testExceptionHandler() {
     $this->assertText($error_pdo_exception['%type'], new FormattableMarkup('Found %type in error page.', $error_pdo_exception));
     $this->assertText($error_pdo_exception['@message'], new FormattableMarkup('Found @message in error page.', $error_pdo_exception));
     $error_details = new FormattableMarkup('in %function (line ', $error_pdo_exception);
-    $this->assertRaw($error_details, new FormattableMarkup("Found '@message' in error page.", ['@message' => $error_details]));
+    $this->assertSession()->responseContains($error_details, new FormattableMarkup("Found '@message' in error page.", ['@message' => $error_details]));
 
     $this->drupalGet('error-test/trigger-renderer-exception');
     $this->assertSession()->statusCodeEquals(500);
@@ -152,7 +152,7 @@ public function testExceptionHandler() {
    */
   public function assertErrorMessage(array $error) {
     $message = new FormattableMarkup('%type: @message in %function (line ', $error);
-    $this->assertRaw($message, new FormattableMarkup('Found error message: @message.', ['@message' => $message]));
+    $this->assertSession()->responseContains($message, new FormattableMarkup('Found error message: @message.', ['@message' => $message]));
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/System/FrontPageTest.php b/core/modules/system/tests/src/Functional/System/FrontPageTest.php
index 9548dfbd73..c2d3bc06bb 100644
--- a/core/modules/system/tests/src/Functional/System/FrontPageTest.php
+++ b/core/modules/system/tests/src/Functional/System/FrontPageTest.php
@@ -75,7 +75,7 @@ public function testDrupalFrontPage() {
     // Change the front page to a path without a starting slash.
     $edit = ['site_frontpage' => $this->nodePath];
     $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']]));
+    $this->assertSession()->responseContains(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']]));
 
     // 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 87a0c1ec23..dc07596575 100644
--- a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
+++ b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
@@ -52,7 +52,7 @@ public function testPageNotFound() {
       'site_404' => 'user/' . $this->adminUser->id(),
     ];
     $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
-    $this->assertRaw(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
+    $this->assertSession()->responseContains(new FormattableMarkup("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
 
     // 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 46c8abe1ec..09af8281bb 100644
--- a/core/modules/system/tests/src/Functional/System/PageTitleTest.php
+++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php
@@ -91,11 +91,11 @@ public function testTitleXSS() {
     $this->assertNoRaw($title, 'Check for the lack of the unfiltered version of the 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>', 'Check for the filtered version of the title in a <title> tag.');
+    $this->assertSession()->responseContains($title_filtered . '</title>', 'Check for the filtered version of the title in a <title> tag.');
 
     // Test the slogan.
     $this->assertNoRaw($slogan, 'Check for the unfiltered version of the slogan.');
-    $this->assertRaw($slogan_filtered, 'Check for the filtered version of the slogan.');
+    $this->assertSession()->responseContains($slogan_filtered, 'Check for the filtered version of the slogan.');
   }
 
   /**
@@ -154,10 +154,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 21c1a85dd5..4dc3a903e6 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 0da67f459f..78513cc6c4 100644
--- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
+++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php
@@ -56,7 +56,7 @@ public function testSiteMaintenance() {
     $permission_label = $permissions['access site in maintenance mode']['title'];
     $permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => Url::fromRoute('user.admin_permissions')->toString(), ':user-login' => Url::fromRoute('user.login')->toString()]);
     $this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
-    $this->assertRaw($permission_message, 'Found the permission message.');
+    $this->assertSession()->responseContains($permission_message, 'Found the permission message.');
 
     $this->drupalGet(Url::fromRoute('user.page'));
     // JS should be aggregated, so drupal.js is not in the page source.
@@ -76,7 +76,7 @@ public function testSiteMaintenance() {
     // JS should not be aggregated, so drupal.js is expected in the page source.
     $links = $this->xpath('//script[contains(@src, :href)]', [':href' => '/core/misc/drupal.js']);
     $this->assertTrue(isset($links[0]), 'script /core/misc/drupal.js in page');
-    $this->assertRaw($admin_message, 'Found the site maintenance mode message.');
+    $this->assertSession()->responseContains($admin_message, 'Found the site maintenance mode message.');
 
     // Logout and verify that offline message is displayed.
     $this->drupalLogout();
@@ -121,7 +121,7 @@ public function testSiteMaintenance() {
     $this->drupalLogout();
     $this->drupalGet('');
     $this->assertEqual('Site under maintenance', $this->cssSelect('main h1')[0]->getText());
-    $this->assertRaw($offline_message, 'Found the site offline message.');
+    $this->assertSession()->responseContains($offline_message, 'Found the site offline message.');
 
     // Verify that custom site offline message is not displayed on user/password.
     $this->drupalGet('user/password');
@@ -161,7 +161,7 @@ public function testNonHtmlRequest() {
       $this->pass('Testing format ' . $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()->responseContains('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/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php
index 09f27a5ba0..a4d3e43baf 100644
--- a/core/modules/system/tests/src/Functional/System/StatusTest.php
+++ b/core/modules/system/tests/src/Functional/System/StatusTest.php
@@ -64,7 +64,7 @@ public function testStatusPage() {
     $this->assertNoText(t('Out of date'));
 
     // The setting config_sync_directory is not properly formed.
-    $this->assertRaw(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]));
+    $this->assertSession()->responseContains(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]));
 
     // Set the schema version of update_test_postupdate to a lower version, so
     // update_test_postupdate_update_8001() needs to be executed.
diff --git a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
index 0993bfae09..a7a3f7bd43 100644
--- a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
+++ b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
@@ -55,12 +55,12 @@ public function testFileTransferHooks() {
     $this->assertNoText('It appears you have reached this page in error.');
     $this->assertText('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()->responseContains('System Test FileTransfer');
     // Make sure the settings form callback works.
     $this->assertText('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 cb2d799311..4555792575 100644
--- a/core/modules/system/tests/src/Functional/System/ThemeTest.php
+++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php
@@ -287,16 +287,16 @@ public function testAdministrationTheme() {
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
 
     $this->drupalGet('admin/config');
-    $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
+    $this->assertSession()->responseContains('core/themes/seven', 'Administration theme used on an administration page.');
 
     $this->drupalGet('node/' . $this->node->id());
-    $this->assertRaw('core/themes/classy', 'Site default theme used on node page.');
+    $this->assertSession()->responseContains('core/themes/classy', 'Site default theme used on node page.');
 
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/seven', 'Administration theme used on the add content page.');
+    $this->assertSession()->responseContains('core/themes/seven', 'Administration theme used on the add content page.');
 
     $this->drupalGet('node/' . $this->node->id() . '/edit');
-    $this->assertRaw('core/themes/seven', 'Administration theme used on the edit content page.');
+    $this->assertSession()->responseContains('core/themes/seven', 'Administration theme used on the edit content page.');
 
     // Disable the admin theme on the node admin pages.
     $edit = [
@@ -305,18 +305,18 @@ public function testAdministrationTheme() {
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
 
     $this->drupalGet('admin/config');
-    $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
+    $this->assertSession()->responseContains('core/themes/seven', 'Administration theme used on an administration page.');
 
     // Ensure that the admin theme is also visible on the 403 page.
     $normal_user = $this->drupalCreateUser(['view the administration theme']);
     $this->drupalLogin($normal_user);
     $this->drupalGet('admin/config');
     $this->assertSession()->statusCodeEquals(403);
-    $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
+    $this->assertSession()->responseContains('core/themes/seven', 'Administration theme used on an administration page.');
     $this->drupalLogin($this->adminUser);
 
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
+    $this->assertSession()->responseContains('core/themes/classy', 'Site default theme used on the add content page.');
 
     // Reset to the default theme settings.
     $edit = [
@@ -326,10 +326,10 @@ public function testAdministrationTheme() {
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
 
     $this->drupalGet('admin');
-    $this->assertRaw('core/themes/classy', 'Site default theme used on administration page.');
+    $this->assertSession()->responseContains('core/themes/classy', 'Site default theme used on administration page.');
 
     $this->drupalGet('node/add');
-    $this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
+    $this->assertSession()->responseContains('core/themes/classy', 'Site default theme used on the add content page.');
   }
 
   /**
@@ -417,7 +417,7 @@ public function testUninstallingThemes() {
     $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
 
     // Check that seven can be uninstalled now.
-    $this->assertRaw('Uninstall Seven theme', 'A link to uninstall the Seven theme does appear on the theme settings page.');
+    $this->assertSession()->responseContains('Uninstall Seven theme', 'A link to uninstall the Seven theme does appear on the theme settings page.');
     // Check that the classy theme still cannot be uninstalled as it is a
     // base theme of bartik.
     $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
@@ -426,7 +426,7 @@ public function testUninstallingThemes() {
     $this->clickLink(t('Set as default'), 1);
 
     // Check that bartik can be uninstalled now.
-    $this->assertRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does appear on the theme settings page.');
+    $this->assertSession()->responseContains('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does appear on the theme settings page.');
 
     // Check that the classy theme still can't be uninstalled as neither of its
     // base themes have been.
@@ -434,10 +434,10 @@ public function testUninstallingThemes() {
 
     // Uninstall each of the three themes starting with Bartik.
     $this->clickLink(t('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(t('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->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
index bdf65203dd..c59e511423 100644
--- a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
+++ b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php
@@ -36,8 +36,8 @@ public function testStatusPageWithoutConfiguration() {
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(t('Trusted Host Settings'));
-    $this->assertRaw(t('The trusted_host_patterns setting is not configured in settings.php.'));
+    $this->assertSession()->responseContains(t('Trusted Host Settings'));
+    $this->assertSession()->responseContains(t('The trusted_host_patterns setting is not configured in settings.php.'));
   }
 
   /**
@@ -54,8 +54,8 @@ public function testStatusPageWithConfiguration() {
     $this->drupalGet('admin/reports/status');
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(t('Trusted Host Settings'));
-    $this->assertRaw(t('The trusted_host_patterns setting is set to allow'));
+    $this->assertSession()->responseContains(t('Trusted Host Settings'));
+    $this->assertSession()->responseContains(t('The trusted_host_patterns setting is set to allow'));
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
index 470c28aab5..562f800d96 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>');
     }
   }
 
@@ -134,7 +134,7 @@ public function testTwigUrlToString() {
   public function testTwigFileUrls() {
     $this->drupalGet('/twig-theme-test/file-url');
     $filepath = file_url_transform_relative(file_create_url('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>');
   }
 
   /**
@@ -142,7 +142,7 @@ public function testTwigFileUrls() {
    */
   public function testTwigAttachLibrary() {
     $this->drupalGet('/twig-theme-test/attach-library');
-    $this->assertRaw('ckeditor.js');
+    $this->assertSession()->responseContains('ckeditor.js');
   }
 
   /**
@@ -150,7 +150,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 762acaca34..81ff31489e 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->assertNoText('registry initialized', 'The registry was not initialized');
   }
 
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
index 895d0f9b0f..6f99cd81a9 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 5a8659b16e..99f5719ebe 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->assertText('Every plant is not a mineral.', 'Success: String filtered.');
     // 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 85464dcf56..0a93f70d01 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php
@@ -155,17 +155,17 @@ protected function assertTwigTransTags() {
       '{% trans %} with {% plural count = 2 %} was successfully translated.'
     );
 
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       'ESCAPEE: &amp;&quot;&lt;&gt;',
       '{{ token }} was successfully translated and prefixed with "@".'
     );
 
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       'PLAYSHOLDR: <em class="placeholder">&amp;&quot;&lt;&gt;</em>',
       '{{ token|placeholder }} was successfully translated and prefixed with "%".'
     );
 
-    $this->assertRaw(
+    $this->assertSession()->responseContains(
       'DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;.',
       '{{ complex.tokens }} were successfully translated with appropriate prefixes.'
     );
@@ -213,7 +213,7 @@ protected function installLanguages() {
 
         // Install the language in Drupal.
         $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
-        $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
+        $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
 
         // 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 60c1ef7d8f..f418a4c313 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->assertText('Test title');
     $this->assertText('Test body');
     $this->assertFieldChecked('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->assertText('0.1');
     $this->assertText('0.2');
-    $this->assertRaw('+31612345678');
-    $this->assertRaw('+31612345679');
+    $this->assertSession()->responseContains('+31612345678');
+    $this->assertSession()->responseContains('+31612345679');
     $this->assertText('Test Article - New title');
     $this->assertText('test.txt');
     $this->assertText('druplicon.small');
-    $this->assertRaw('General discussion');
+    $this->assertSession()->responseContains('General discussion');
     $this->assertText('Test Article - New title');
     $this->assertText('Test 1');
-    $this->assertRaw('0.01');
+    $this->assertSession()->responseContains('0.01');
     $this->drupalPostForm('node/8/edit', [], 'Save (this translation)');
     $this->assertSession()->statusCodeEquals(200);
     $this->drupalGet('node/8/edit', ['language' => $spanish]);
@@ -133,7 +133,7 @@ public function testUpdatedSite() {
     // Make sure the user page is correct.
     $this->drupalGet('user/3');
     $this->assertText('usuario_test');
-    $this->assertRaw('druplicon.small');
+    $this->assertSession()->responseContains('druplicon.small');
     $this->assertText('Test file field');
     $this->assertLink('test.txt');
 
@@ -154,14 +154,14 @@ public function testUpdatedSite() {
     $this->clickLink('Test Article - New title');
     $this->assertText('Body');
     $this->assertText('Tags');
-    $this->assertRaw('Text format');
+    $this->assertSession()->responseContains('Text format');
 
     // Make sure that users still exist.
     $this->drupalGet('admin/people');
     $this->assertText('usuario_test');
     $this->assertText('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');
@@ -184,7 +184,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');
@@ -216,7 +216,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->assertFieldChecked('edit-enabled-value');
@@ -310,7 +310,7 @@ public function testUpdatedSite() {
     $this->assertText('Test action');
     $this->drupalGet('admin/config/system/actions/configure/test_action');
     $this->assertText('test_action');
-    $this->assertRaw('drupal.org');
+    $this->assertSession()->responseContains('drupal.org');
 
     // Make sure our ban still exists.
     $this->drupalGet('admin/config/people/ban');
@@ -337,7 +337,7 @@ public function testUpdatedSite() {
     $this->assertText('Hello');
     $this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit');
     $this->assertText('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/UpdatePostUpdateFailingTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php
index 3d799fe7cc..80067b8a98 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php
@@ -76,8 +76,8 @@ public function testPostUpdate() {
    */
   protected function doSelectionTest() {
     // First update, should not be run since this module's update hooks fail.
-    $this->assertRaw('8001 -   This update will fail.');
-    $this->assertRaw('8002 -   A further update.');
+    $this->assertSession()->responseContains('8001 -   This update will fail.');
+    $this->assertSession()->responseContains('8002 -   A further update.');
     $this->assertEscaped("First update, should not be run since this module's update hooks fail.");
   }
 
diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
index 99265399e6..34810d485f 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php
@@ -75,7 +75,7 @@ protected function setUp(): void {
   protected function doSelectionTest() {
     // Ensure that normal and post_update updates are merged together on the
     // selection page.
-    $this->assertRaw('<ul><li>8001 -   Normal update_N() function. </li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>');
+    $this->assertSession()->responseContains('<ul><li>8001 -   Normal update_N() function. </li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>');
   }
 
   /**
@@ -84,16 +84,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()->responseContains('First update');
+    $this->assertSession()->responseContains('<h3>Update second</h3>');
+    $this->assertSession()->responseContains('Second update');
+    $this->assertSession()->responseContains('<h3>Update test1</h3>');
+    $this->assertSession()->responseContains('Test1 update');
+    $this->assertSession()->responseContains('<h3>Update test0</h3>');
+    $this->assertSession()->responseContains('Test0 update');
+    $this->assertSession()->responseContains('<h3>Update test_batch</h3>');
+    $this->assertSession()->responseContains('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 95efd30eac..658716f9ac 100644
--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
+++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php
@@ -66,7 +66,7 @@ public function testUpdateHooks() {
     $this->drupalGet($this->updateUrl, ['external' => TRUE]);
     $this->updateRequirementsProblem();
     $this->clickLink(t('Continue'));
-    $this->assertRaw('Schema version 8001.');
+    $this->assertSession()->responseContains('Schema version 8001.');
     // Run the update hooks.
     $this->clickLink(t('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 3befd2336d..bd7e08e589 100644
--- a/core/modules/taxonomy/tests/src/Functional/RssTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php
@@ -106,7 +106,7 @@ public function testTaxonomyRss() {
       'domain="' . $term1->toUrl('canonical', ['absolute' => TRUE])->toString() . '"',
       $term1->getName()
     );
-    $this->assertRaw($test_element, 'Term is displayed when viewing the rss feed.');
+    $this->assertSession()->responseContains($test_element, 'Term is displayed when viewing the rss feed.');
 
     // Test that the feed icon exists for the term.
     $this->drupalGet("taxonomy/term/{$term1->id()}");
@@ -133,7 +133,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, "Raw text '$raw_xml' is found.");
+    $this->assertSession()->responseContains($raw_xml, "Raw text '$raw_xml' is found.");
     // 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 0f38a4cb95..85f2846d83 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermIndexTest.php
@@ -219,7 +219,7 @@ public function testTaxonomyTermHierarchyBreadcrumbs() {
     $this->drupalGet('taxonomy/term/' . $term1->id());
     // Breadcrumbs are not rendered with a language, prevent the term
     // language from being added to the options.
-    $this->assertRaw(Link::fromTextAndUrl($term2->getName(), $term2->toUrl('canonical', ['language' => NULL]))->toString(), 'Parent term link is displayed when viewing the node.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl($term2->getName(), $term2->toUrl('canonical', ['language' => NULL]))->toString(), 'Parent term link is displayed when viewing the node.');
   }
 
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php
index b4ca5364db..f8fd814d83 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php
@@ -256,7 +256,7 @@ public function testNodeTermCreationAndDeletion() {
 
     // Verify the placeholder is there.
     $this->drupalGet('node/add/article');
-    $this->assertRaw('placeholder="Start typing here."', 'Placeholder is present.');
+    $this->assertSession()->responseContains('placeholder="Start typing here."', 'Placeholder is present.');
 
     // Preview and verify the terms appear but are not created.
     $this->drupalPostForm(NULL, $edit, t('Preview'));
@@ -341,7 +341,7 @@ public function testTermInterface() {
 
     $this->clickLink(t('Edit'));
 
-    $this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.');
+    $this->assertSession()->responseContains($edit['name[0][value]'], 'The randomly generated term name is present.');
     $this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
 
     $edit = [
@@ -573,9 +573,9 @@ public function testReSavingTags() {
     // Check that the term is displayed when editing and saving the node with no
     // changes.
     $this->clickLink(t('Edit'));
-    $this->assertRaw($term->getName(), 'Term is displayed when editing the node.');
+    $this->assertSession()->responseContains($term->getName(), 'Term is displayed when editing the node.');
     $this->drupalPostForm(NULL, [], t('Save'));
-    $this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
+    $this->assertSession()->responseContains($term->getName(), 'Term is displayed after saving the node with no changes.');
   }
 
   /**
diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
index a64a0590f8..8278cba8ee 100644
--- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
+++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php
@@ -162,7 +162,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
index 83f4a88723..777acc0aec 100644
--- a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php
@@ -39,16 +39,16 @@ public function testTaxonomyTermThemes() {
     // should use the administrative theme.
     $vocabulary = $this->createVocabulary();
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
-    $this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for adding a taxonomy term."));
+    $this->assertSession()->responseContains('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for adding a taxonomy term."));
 
     // Viewing a taxonomy term should use the default theme.
     $term = $this->createTerm($vocabulary);
     $this->drupalGet('taxonomy/term/' . $term->id());
-    $this->assertRaw('bartik/css/base/elements.css', t("The default theme's CSS appears on the page for viewing a taxonomy term."));
+    $this->assertSession()->responseContains('bartik/css/base/elements.css', t("The default theme's CSS appears on the page for viewing a taxonomy term."));
 
     // Editing a taxonomy term should use the same theme as adding one.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
-    $this->assertRaw('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for editing a taxonomy term."));
+    $this->assertSession()->responseContains('seven/css/base/elements.css', t("The administrative theme's CSS appears on the page for editing a taxonomy term."));
   }
 
 }
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
index 85d17a3b15..cd76c3d6c1 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php
@@ -265,11 +265,11 @@ public function testVocabularyPermissionsTaxonomyTerm() {
 
     // Delete the vocabulary.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
-    $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]']]), 'Delete taxonomy term form opened successfully.');
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]']]), 'Delete taxonomy term form opened successfully.');
 
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]), 'Term deleted.');
+    $this->assertSession()->responseContains(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]), 'Term deleted.');
 
     // Test as user with "create" permissions.
     $user = $this->drupalCreateUser(["create terms in {$vocabulary->id()}"]);
@@ -345,11 +345,11 @@ public function testVocabularyPermissionsTaxonomyTerm() {
 
     // Delete the vocabulary.
     $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
-    $this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $term->getName()]), 'Delete taxonomy term form opened successfully.');
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $term->getName()]), 'Delete taxonomy term form opened successfully.');
 
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('Deleted term %name.', ['%name' => $term->getName()]), 'Term deleted.');
+    $this->assertSession()->responseContains(t('Deleted term %name.', ['%name' => $term->getName()]), 'Term deleted.');
 
     // Test as user without proper permissions.
     $user = $this->drupalCreateUser();
diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
index b2854e5aee..99162e5cc4 100644
--- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php
@@ -47,7 +47,7 @@ public function testVocabularyInterface() {
     $edit['description'] = $this->randomMachineName();
     $edit['vid'] = $vid;
     $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Created new vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary created successfully.');
+    $this->assertSession()->responseContains(t('Created new vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary created successfully.');
 
     // Edit the vocabulary.
     $this->drupalGet('admin/structure/taxonomy');
@@ -150,12 +150,12 @@ public function testTaxonomyAdminDeletingVocabulary() {
     // Delete the vocabulary.
     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
     $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()]), '[confirm deletion] Asks for confirmation.');
+    $this->assertSession()->responseContains(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()]), '[confirm deletion] Asks for confirmation.');
     $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[confirm deletion] Inform that all terms will be deleted.');
 
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('Deleted vocabulary %name.', ['%name' => $vocabulary->label()]), 'Vocabulary deleted.');
+    $this->assertSession()->responseContains(t('Deleted vocabulary %name.', ['%name' => $vocabulary->label()]), 'Vocabulary deleted.');
     $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache();
     $this->assertNull(Vocabulary::load($vid), 'Vocabulary not found.');
   }
diff --git a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
index e066012fb3..5ed5bfc997 100644
--- a/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
+++ b/core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php
@@ -86,7 +86,7 @@ protected function setUp(): void {
   public function testTelephoneWidget() {
     $this->drupalGet('node/add/article');
     $this->assertFieldByName("field_telephone[0][value]", '', 'Widget found.');
-    $this->assertRaw('placeholder="123-456-7890"');
+    $this->assertSession()->responseContains('placeholder="123-456-7890"');
   }
 
   /**
@@ -104,7 +104,7 @@ public function testTelephoneFormatter($input, $expected) {
     ];
 
     $this->drupalPostForm('node/add/article', $edit, t('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 4544a97740..98e91a5249 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
@@ -103,7 +103,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();
@@ -181,7 +181,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();
 
@@ -191,7 +191,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();
 
@@ -283,7 +283,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() {
     t($name, [], ['langcode' => $langcode]);
     // Reset locale cache.
     $this->container->get('string_translation')->reset();
-    $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
+    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
     $this->assertText(t($name), 'Test language added.');
 
     // Have the adminUser request a page in the new language.
@@ -406,7 +406,7 @@ public function testExternalLink() {
     $this->drupalGet(Url::fromRoute('<front>'));
     $this->assertText('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 fee6f2666b..d04042a9ef 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 ea5473e666..5f6cbb4a10 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -232,7 +232,7 @@ public function testTrackerUser() {
     Cache::invalidateTags(['rendered']);
     $this->drupalGet('user/' . $this->user->id() . '/activity');
     $this->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 14b2a53eab..6aff131e64 100644
--- a/core/modules/update/tests/src/Functional/UpdateContribTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -68,10 +68,10 @@ public function testNoReleasesAvailable() {
     $this->drupalGet('admin/reports/updates');
     // Cannot use $this->standardTests() because we need to check for the
     // 'No available releases found' string.
-    $this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
-    $this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
+    $this->assertSession()->responseContains('<h3>' . t('Drupal core') . '</h3>');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString());
     $this->assertText(t('Up to date'));
-    $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+    $this->assertSession()->responseContains('<h3>' . t('Modules') . '</h3>');
     $this->assertNoText(t('Update available'));
     $this->assertText(t('No available releases found'));
     $this->assertNoRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString());
@@ -104,9 +104,9 @@ public function testUpdateContribBasic() {
     );
     $this->standardTests();
     $this->assertText(t('Up to date'));
-    $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+    $this->assertSession()->responseContains('<h3>' . t('Modules') . '</h3>');
     $this->assertNoText(t('Update available'));
-    $this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
+    $this->assertSession()->responseContains($project_link, 'Link to aaa_update_test project appears.');
 
     // 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, 'Link to aaa_update_test project appears.');
+    $this->assertSession()->responseContains($project_link, 'Link to aaa_update_test project appears.');
   }
 
   /**
@@ -192,8 +192,8 @@ public function testUpdateContribOrder() {
     // its own project on the report.
     $this->assertNoRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project does not appear.');
     // 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(), 'Link to bbb_update_test project appears.');
-    $this->assertRaw(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString(), 'Link to bbb_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString(), 'Link to bbb_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString(), 'Link to bbb_update_test project appears.');
 
     // 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
@@ -240,7 +240,7 @@ public function testUpdateBaseThemeSecurityUpdate() {
     ];
     $this->refreshUpdateStatus($xml_mapping);
     $this->assertText(t('Security update required!'));
-    $this->assertRaw(Link::fromTextAndUrl(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'))->toString(), 'Link to the Update test base theme project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'))->toString(), 'Link to the Update test base theme project appears.');
   }
 
   /**
@@ -396,8 +396,8 @@ public function testUpdateShowDisabledThemes() {
       $this->assertNoText(t('Themes'));
       if ($check_disabled) {
         $this->assertText(t('Uninstalled themes'));
-        $this->assertRaw($base_theme_project_link, 'Link to the Update test base theme project appears.');
-        $this->assertRaw($sub_theme_project_link, 'Link to the Update test subtheme project appears.');
+        $this->assertSession()->responseContains($base_theme_project_link, 'Link to the Update test base theme project appears.');
+        $this->assertSession()->responseContains($sub_theme_project_link, 'Link to the Update test subtheme project appears.');
       }
       else {
         $this->assertNoText(t('Uninstalled themes'));
@@ -485,16 +485,16 @@ public function testUpdateBrokenFetchURL() {
     // We need to check that this string is found as part of a project row, not
     // just in the "Failed to get available update data" message at the top of
     // the page.
-    $this->assertRaw('<div class="project-update__status">' . t('Failed to get available update data'));
+    $this->assertSession()->responseContains('<div class="project-update__status">' . t('Failed to get available update data'));
 
     // We should see the output messages from fetching manually.
     $this->assertUniqueText(t('Checked available update data for 3 projects.'));
     $this->assertUniqueText(t('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(), 'Link to aaa_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project appears.');
     $this->assertNoRaw(Link::fromTextAndUrl(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test'))->toString(), 'Link to bbb_update_test project does not appear.');
-    $this->assertRaw(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString(), 'Link to bbb_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test'))->toString(), 'Link to bbb_update_test project appears.');
   }
 
   /**
@@ -534,17 +534,17 @@ public function testHookUpdateStatusAlter() {
       ]
     );
     $this->drupalGet('admin/reports/updates');
-    $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+    $this->assertSession()->responseContains('<h3>' . t('Modules') . '</h3>');
     $this->assertText(t('Security update required!'));
-    $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project appears.');
 
     // Visit the reports page again without the altering and make sure the
     // status is back to normal.
     $update_test_config->set('update_status', [])->save();
     $this->drupalGet('admin/reports/updates');
-    $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+    $this->assertSession()->responseContains('<h3>' . t('Modules') . '</h3>');
     $this->assertNoText(t('Security update required!'));
-    $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project appears.');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString(), 'Link to aaa_update_test project appears.');
 
     // 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/UpdateCoreTest.php b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
index 59257c7fcf..fa7e6ea51d 100644
--- a/core/modules/update/tests/src/Functional/UpdateCoreTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
@@ -84,7 +84,7 @@ public function testNoUpdatesAvailable() {
           $this->assertText(t('Up to date'));
           $this->assertNoText(t('Update available'));
           $this->assertNoText(t('Security update required!'));
-          $this->assertRaw('check.svg', 'Check icon was found.');
+          $this->assertSession()->responseContains('check.svg', 'Check icon was found.');
         }
       }
     }
diff --git a/core/modules/update/tests/src/Functional/UpdateTestBase.php b/core/modules/update/tests/src/Functional/UpdateTestBase.php
index 80f5b2496c..d78ed68cf7 100644
--- a/core/modules/update/tests/src/Functional/UpdateTestBase.php
+++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php
@@ -106,8 +106,8 @@ protected function refreshUpdateStatus($xml_map, $url = 'update-test') {
    * Runs a series of assertions that are applicable to all update statuses.
    */
   protected function standardTests() {
-    $this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
-    $this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString(), 'Link to the Drupal project appears.');
+    $this->assertSession()->responseContains('<h3>' . t('Drupal core') . '</h3>');
+    $this->assertSession()->responseContains(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString(), 'Link to the Drupal project appears.');
     $this->assertNoText(t('No available releases found'));
   }
 
diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
index 6e431e10fa..4dfa4de898 100644
--- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php
+++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php
@@ -84,7 +84,7 @@ public function testUploadModule() {
     $this->assertSession()->titleEquals('Update manager | Drupal');
     // Check for a success message on the page, and check that the installed
     // module now exists in the expected place in the filesystem.
-    $this->assertRaw(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
+    $this->assertSession()->responseContains(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
     $this->assertFileExists($installedInfoFilePath);
     // Ensure the links are relative to the site root and not
     // core/authorize.php.
@@ -129,7 +129,7 @@ public function testUploadModule() {
     $this->drupalPostForm('admin/reports/updates/update', ['projects[update_test_new_module]' => TRUE], t('Download these updates'));
     $this->drupalPostForm(NULL, ['maintenance_mode' => FALSE], t('Continue'));
     $this->assertText(t('Update was completed successfully.'));
-    $this->assertRaw(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
+    $this->assertSession()->responseContains(t('Installed %project_name successfully', ['%project_name' => 'update_test_new_module']));
 
     // Parse the info file again to check that the module has been updated to
     // 8.x-1.1.
diff --git a/core/modules/user/tests/src/Functional/UserAdminTest.php b/core/modules/user/tests/src/Functional/UserAdminTest.php
index a428bac8c8..e168246711 100644
--- a/core/modules/user/tests/src/Functional/UserAdminTest.php
+++ b/core/modules/user/tests/src/Functional/UserAdminTest.php
@@ -63,7 +63,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, 'Found user A edit link on admin users page');
+    $this->assertSession()->responseContains($link, 'Found user A edit link on admin users page');
 
     // Test exposed filter elements.
     foreach (['user', 'role', 'permission', 'status'] as $field) {
@@ -165,7 +165,7 @@ public function testNotificationEmailAddress() {
     $admin_user = $this->drupalCreateUser(['administer users', 'administer account settings']);
     $this->drupalLogin($admin_user);
     $this->drupalGet('admin/config/people/accounts');
-    $this->assertRaw('id="edit-mail-notification-address"', 'Notification Email address field exists');
+    $this->assertSession()->responseContains('id="edit-mail-notification-address"', 'Notification Email address field exists');
     $this->drupalLogout();
 
     // Test custom user registration approval email address(es).
diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php
index 8b67a1c890..5297fff0c1 100644
--- a/core/modules/user/tests/src/Functional/UserCancelTest.php
+++ b/core/modules/user/tests/src/Functional/UserCancelTest.php
@@ -90,7 +90,7 @@ public function testUserCancelChangePermission() {
     $this->drupalPostForm('user_form_test_cancel/' . $account->id(), [], t('Cancel account'));
 
     // Confirm deletion.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
+    $this->assertSession()->responseContains(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
@@ -204,7 +204,7 @@ public function testUserBlock() {
     $this->assertTrue($account->isBlocked(), 'User has been blocked.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
+    $this->assertSession()->responseContains(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
   }
 
   /**
@@ -261,7 +261,7 @@ public function testUserBlockUnpublish() {
     $this->assertSession()->addressEquals('');
     $this->assertSession()->statusCodeEquals(200);
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
+    $this->assertSession()->responseContains(t('%name has been disabled.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
 
     $user_storage->resetCache([$account->id()]);
     $account = $user_storage->load($account->id());
@@ -328,7 +328,7 @@ public function testUserAnonymize() {
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
-    $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
+    $this->assertSession()->responseContains(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
 
     // Confirm account cancellation.
     $timestamp = time();
@@ -358,7 +358,7 @@ public function testUserAnonymize() {
     $this->assertEqual($test_comment->getAuthorName(), $anonymous_user->getDisplayName(), 'Comment of the user has been attributed to anonymous user name.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
+    $this->assertSession()->responseContains(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
   }
 
   /**
@@ -388,7 +388,7 @@ public function testUserAnonymizeBatch() {
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
-    $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
+    $this->assertSession()->responseContains(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')]), 'Informs that all content will be attributed to anonymous account.');
 
     // Confirm account cancellation.
     $timestamp = time();
@@ -477,7 +477,7 @@ public function testUserDelete() {
     $this->assertNull(Comment::load($comment->id()), 'Comment of the user has been deleted.');
 
     // Confirm that the confirmation message made it through to the end user.
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
+    $this->assertSession()->responseContains(t('%name has been deleted.', ['%name' => $account->getAccountName()]), "Confirmation message displayed to user.");
   }
 
   /**
@@ -496,12 +496,12 @@ public function testUserCancelByAdmin() {
     // Delete regular user.
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
-    $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.');
+    $this->assertSession()->responseContains(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
 
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
+    $this->assertSession()->responseContains(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
@@ -524,12 +524,12 @@ public function testUserWithoutEmailCancelByAdmin() {
     // Delete regular user without email address.
     $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
-    $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.');
+    $this->assertSession()->responseContains(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()]), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
 
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Cancel account'));
-    $this->assertRaw(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
+    $this->assertSession()->responseContains(t('%name has been deleted.', ['%name' => $account->getAccountName()]), 'User deleted.');
     $this->assertNull(User::load($account->id()), 'User is not found in the database.');
   }
 
diff --git a/core/modules/user/tests/src/Functional/UserCreateTest.php b/core/modules/user/tests/src/Functional/UserCreateTest.php
index fef1a53b05..014e0f35a9 100644
--- a/core/modules/user/tests/src/Functional/UserCreateTest.php
+++ b/core/modules/user/tests/src/Functional/UserCreateTest.php
@@ -88,7 +88,7 @@ public function testUserAdd() {
 
     $config->set('password_strength', TRUE)->save();
     $this->drupalGet('admin/people/create');
-    $this->assertRaw(t('Password strength:'), 'The password strength indicator is displayed.');
+    $this->assertSession()->responseContains(t('Password strength:'), 'The password strength indicator is displayed.');
 
     $config->set('password_strength', FALSE)->save();
     $this->drupalGet('admin/people/create');
diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php
index 6a71927a96..5b3725d766 100644
--- a/core/modules/user/tests/src/Functional/UserEditTest.php
+++ b/core/modules/user/tests/src/Functional/UserEditTest.php
@@ -29,7 +29,7 @@ public function testUserEdit() {
     // Test that error message appears when attempting to use a non-unique user name.
     $edit['name'] = $user2->getAccountName();
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t('The username %name is already taken.', ['%name' => $edit['name']]));
+    $this->assertSession()->responseContains(t('The username %name is already taken.', ['%name' => $edit['name']]));
 
     // Check that the default value in user name field
     // is the raw value and not a formatted one.
@@ -61,23 +61,23 @@ public function testUserEdit() {
     $edit = [];
     $edit['mail'] = $this->randomMachineName() . '@new.example.com';
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')]));
+    $this->assertSession()->responseContains(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')]));
 
     $edit['current_pass'] = $user1->passRaw;
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->responseContains(t("The changes have been saved."));
 
     // Test that the user must enter current password before changing passwords.
     $edit = [];
     $edit['pass[pass1]'] = $new_pass = $this->randomMachineName();
     $edit['pass[pass2]'] = $new_pass;
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')]));
+    $this->assertSession()->responseContains(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')]));
 
     // Try again with the current password.
     $edit['current_pass'] = $user1->passRaw;
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->responseContains(t("The changes have been saved."));
 
     // Make sure the changed timestamp is updated.
     $this->assertEqual($user1->getChangedTime(), REQUEST_TIME, 'Changing a user sets "changed" timestamp.');
@@ -94,7 +94,7 @@ public function testUserEdit() {
 
     $config->set('password_strength', TRUE)->save();
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t('Password strength:'), 'The password strength indicator is displayed.');
+    $this->assertSession()->responseContains(t('Password strength:'), 'The password strength indicator is displayed.');
 
     $config->set('password_strength', FALSE)->save();
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
@@ -137,7 +137,7 @@ public function testUserWith0Password() {
 
     $edit = ['pass[pass1]' => '0', 'pass[pass2]' => '0'];
     $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save'));
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->responseContains(t("The changes have been saved."));
   }
 
   /**
@@ -153,7 +153,7 @@ public function testUserWithoutEmailEdit() {
     $user1->mail = '';
     $user1->save();
     $this->drupalPostForm("user/" . $user1->id() . "/edit", ['mail' => ''], t('Save'));
-    $this->assertRaw(t("The changes have been saved."));
+    $this->assertSession()->responseContains(t("The changes have been saved."));
   }
 
   /**
diff --git a/core/modules/user/tests/src/Functional/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php
index e067915867..6cefd3eb8c 100644
--- a/core/modules/user/tests/src/Functional/UserLoginTest.php
+++ b/core/modules/user/tests/src/Functional/UserLoginTest.php
@@ -169,11 +169,11 @@ public function assertFailedLogin($account, $flood_trigger = NULL) {
     $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
     if (isset($flood_trigger)) {
       if ($flood_trigger == 'user') {
-        $this->assertRaw(\Drupal::translation()->formatPlural($this->config('user.flood')->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
+        $this->assertSession()->responseContains(\Drupal::translation()->formatPlural($this->config('user.flood')->get('user_limit'), 'There has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', 'There have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
       }
       else {
         // No uid, so the limit is IP-based.
-        $this->assertRaw(t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
+        $this->assertSession()->responseContains(t('Too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href=":url">request a new password</a>.', [':url' => Url::fromRoute('user.pass')->toString()]));
       }
     }
     else {
diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
index 5efd7d5c7b..1ff0892ddb 100644
--- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php
@@ -167,7 +167,7 @@ public function testUserPasswordReset() {
     $before = count($this->drupalGetMails(['id' => 'user_password_reset']));
     $edit = ['name' => $blocked_account->getAccountName()];
     $this->drupalPostForm(NULL, $edit, t('Submit'));
-    $this->assertRaw(t('%name is blocked or has not been activated yet.', ['%name' => $blocked_account->getAccountName()]), 'Notified user blocked accounts can not request a new password');
+    $this->assertSession()->responseContains(t('%name is blocked or has not been activated yet.', ['%name' => $blocked_account->getAccountName()]), 'Notified user blocked accounts can not request a new password');
     $this->assertCount($before, $this->drupalGetMails(['id' => 'user_password_reset']), 'No email was sent when requesting password reset for a blocked account');
 
     // Verify a password reset link is invalidated when the user's email address changes.
@@ -232,7 +232,7 @@ public function testUserPasswordResetLoggedIn() {
     // Log in as a different user.
     $this->drupalLogin($this->account);
     $this->drupalGet($resetURL);
-    $this->assertRaw(new FormattableMarkup(
+    $this->assertSession()->responseContains(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()]
     ));
@@ -278,7 +278,7 @@ public function testUserResetPasswordTextboxFilled() {
       'pass' => $this->randomMachineName(),
     ];
     $this->drupalPostForm('user/login', $edit, t('Log in'));
-    $this->assertRaw(t('Unrecognized username or password. <a href=":password">Forgot your password?</a>',
+    $this->assertSession()->responseContains(t('Unrecognized username or password. <a href=":password">Forgot your password?</a>',
       [':password' => Url::fromRoute('user.pass', [], ['query' => ['name' => $edit['name']]])->toString()]));
     unset($edit['pass']);
     $this->drupalGet('user/password', ['query' => ['name' => $edit['name']]]);
diff --git a/core/modules/user/tests/src/Functional/UserPictureTest.php b/core/modules/user/tests/src/Functional/UserPictureTest.php
index b7fd36408a..c0ca0dc701 100644
--- a/core/modules/user/tests/src/Functional/UserPictureTest.php
+++ b/core/modules/user/tests/src/Functional/UserPictureTest.php
@@ -71,7 +71,7 @@ public function testCreateDeletePicture() {
 
     // Verify that the image is displayed on the user account page.
     $this->drupalGet('user');
-    $this->assertRaw(StreamWrapperManager::getTarget($file->getFileUri()), 'User picture found on user account page.');
+    $this->assertSession()->responseContains(StreamWrapperManager::getTarget($file->getFileUri()), 'User picture found on user account page.');
 
     // 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 15c5811dea..1b9f24e478 100644
--- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php
+++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php
@@ -280,11 +280,11 @@ public function testUniqueFields() {
 
     $edit = ['mail' => 'test@example.com', 'name' => $account->getAccountName()];
     $this->drupalPostForm('user/register', $edit, t('Create new account'));
-    $this->assertRaw(new FormattableMarkup('The username %value is already taken.', ['%value' => $account->getAccountName()]));
+    $this->assertSession()->responseContains(new FormattableMarkup('The username %value is already taken.', ['%value' => $account->getAccountName()]));
 
     $edit = ['mail' => $account->getEmail(), 'name' => $this->randomString()];
     $this->drupalPostForm('user/register', $edit, t('Create new account'));
-    $this->assertRaw(new FormattableMarkup('The email address %value is already taken.', ['%value' => $account->getEmail()]));
+    $this->assertSession()->responseContains(new FormattableMarkup('The email address %value is already taken.', ['%value' => $account->getEmail()]));
   }
 
   /**
@@ -339,12 +339,12 @@ public function testRegistrationWithUserFields() {
     $edit['test_user_field[0][value]'] = '';
     $this->drupalPostForm(NULL, $edit, t('Create new account'));
     $this->assertRegistrationFormCacheTagsWithUserFields();
-    $this->assertRaw(t('@name field is required.', ['@name' => $field->label()]), 'Field validation error was correctly reported.');
+    $this->assertSession()->responseContains(t('@name field is required.', ['@name' => $field->label()]), 'Field validation error was correctly reported.');
     // Invalid input.
     $edit['test_user_field[0][value]'] = '-1';
     $this->drupalPostForm(NULL, $edit, t('Create new account'));
     $this->assertRegistrationFormCacheTagsWithUserFields();
-    $this->assertRaw(t('%name does not accept the value -1.', ['%name' => $field->label()]), 'Field validation error was correctly reported.');
+    $this->assertSession()->responseContains(t('%name does not accept the value -1.', ['%name' => $field->label()]), 'Field validation error was correctly reported.');
 
     // Submit with valid data.
     $value = rand(1, 255);
diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
index 8e11fd19b5..6c12f8fec8 100644
--- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
+++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php
@@ -61,7 +61,7 @@ public function testRoleAdministration() {
     $role_name = '123';
     $edit = ['label' => $role_name, 'id' => $role_name];
     $this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
-    $this->assertRaw(t('Role %label has been added.', ['%label' => 123]));
+    $this->assertSession()->responseContains(t('Role %label has been added.', ['%label' => 123]));
     $role = Role::load($role_name);
     $this->assertIsObject($role);
 
@@ -70,13 +70,13 @@ public function testRoleAdministration() {
 
     // Try adding a duplicate role.
     $this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
-    $this->assertRaw(t('The machine-readable name is already in use. It must be unique.'), 'Duplicate role warning displayed.');
+    $this->assertSession()->responseContains(t('The machine-readable name is already in use. It must be unique.'), 'Duplicate role warning displayed.');
 
     // Test renaming a role.
     $role_name = '456';
     $edit = ['label' => $role_name];
     $this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save'));
-    $this->assertRaw(t('Role %label has been updated.', ['%label' => $role_name]));
+    $this->assertSession()->responseContains(t('Role %label has been updated.', ['%label' => $role_name]));
     \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
     $new_role = Role::load($role->id());
     $this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.');
@@ -85,7 +85,7 @@ public function testRoleAdministration() {
     $this->drupalGet("admin/people/roles/manage/{$role->id()}");
     $this->clickLink(t('Delete'));
     $this->drupalPostForm(NULL, [], t('Delete'));
-    $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name]));
+    $this->assertSession()->responseContains(t('The role %label has been deleted.', ['%label' => $role_name]));
     $this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.');
     \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]);
     $this->assertNull(Role::load($role->id()), 'A deleted role can no longer be loaded.');
diff --git a/core/modules/user/tests/src/Functional/UserTranslationUITest.php b/core/modules/user/tests/src/Functional/UserTranslationUITest.php
index 9b8d9ae915..f4e5993410 100644
--- a/core/modules/user/tests/src/Functional/UserTranslationUITest.php
+++ b/core/modules/user/tests/src/Functional/UserTranslationUITest.php
@@ -80,7 +80,7 @@ protected function doTestTranslationEdit() {
           '@title' => $entity->getTranslation($langcode)->label(),
           '%language' => $languages[$langcode]->getName(),
         ]);
-        $this->assertRaw($title);
+        $this->assertSession()->responseContains($title);
       }
     }
   }
diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
index ec6378157e..1f109c0d01 100644
--- a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
+++ b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php
@@ -59,7 +59,7 @@ public function testUserEditAccess() {
     $this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items'));
     $this->assertSession()->statusCodeEquals(200);
 
-    $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [
+    $this->assertSession()->responseContains(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(),
diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php
index 44045ba93a..d87b436479 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(), 'The user is found in the table.');
+    $this->assertSession()->responseContains($account->label(), 'The user is found in the table.');
     $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 149ed5f182..21c6384db5 100644
--- a/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/tests/src/Functional/Views/HandlerFilterUserNameTest.php
@@ -103,7 +103,7 @@ public function testAdminUserInterface() {
       'options[value]' => implode(', ', $users),
     ];
     $this->drupalPostForm($path, $edit, t('Apply'));
-    $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->responseContains(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
 
     // Pass in an invalid username and a valid username.
     $random_name = $this->randomMachineName();
@@ -114,7 +114,7 @@ public function testAdminUserInterface() {
     ];
     $users = [$users[0]];
     $this->drupalPostForm($path, $edit, t('Apply'));
-    $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->responseContains(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
 
     // Pass in just valid usernames.
     $users = $this->names;
@@ -139,7 +139,7 @@ public function testExposedFilter() {
     $users = array_map('strtolower', $users);
     $options['query']['uid'] = implode(', ', $users);
     $this->drupalGet($path, $options);
-    $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->responseContains(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
 
     // Pass in an invalid target_id in for the entity_autocomplete value format.
     // There should be no errors, but all results should be returned as the
@@ -149,7 +149,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()->responseContains($account->id());
     }
 
     // Pass in an invalid username and a valid username.
@@ -159,7 +159,7 @@ public function testExposedFilter() {
     $users = [$users[0]];
 
     $this->drupalGet($path, $options);
-    $this->assertRaw(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
+    $this->assertSession()->responseContains(t('There are no entities matching "%value".', ['%value' => implode(', ', $users)]));
 
     // Pass in just valid usernames.
     $users = $this->names;
@@ -169,7 +169,7 @@ public function testExposedFilter() {
     $this->assertNoRaw('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()->responseContains($account->id());
     }
 
     // Pass in just valid user IDs in the entity_autocomplete target_id format.
@@ -181,7 +181,7 @@ public function testExposedFilter() {
     $this->assertNoRaw('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()->responseContains($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 a4b314cfb2..4abd3c2069 100644
--- a/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/FieldDropButtonTest.php
@@ -61,11 +61,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 5560abaa8d..2326ccff3a 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 efe4615eac..41505d0188 100644
--- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
@@ -219,7 +219,7 @@ public function testExposedBlock() {
 
     // Test that the custom block label is found.
     $this->drupalGet('test_exposed_block');
-    $this->assertRaw('<strong>Custom</strong> titlealert("hacked!");', 'Custom block title found.');
+    $this->assertSession()->responseContains('<strong>Custom</strong> titlealert("hacked!");', 'Custom block title found.');
 
     // Set label to hidden on the exposed filter form block.
     $block->getPlugin()->setConfigurationValue('label_display', FALSE);
@@ -349,7 +349,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->assertNoRaw($escape_2);
     // And not the raw label, either.
@@ -396,15 +396,15 @@ public function testFormErrorWithExposedForm() {
     $this->assertSession()->statusCodeEquals(200);
     $form = $this->cssSelect('form.views-exposed-form');
     $this->assertNotEmpty($form, 'The exposed form element was found.');
-    $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.');
-    $this->assertRaw('<div class="views-row">', 'Views result shown.');
+    $this->assertSession()->responseContains(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.');
+    $this->assertSession()->responseContains('<div class="views-row">', 'Views result shown.');
 
     $this->drupalPostForm(NULL, [], t('Submit'));
     $this->assertSession()->statusCodeEquals(200);
     $form = $this->cssSelect('form.views-exposed-form');
     $this->assertNotEmpty($form, 'The exposed form element was found.');
-    $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.');
-    $this->assertRaw('<div class="views-row">', 'Views result shown.');
+    $this->assertSession()->responseContains(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.');
+    $this->assertSession()->responseContains('<div class="views-row">', 'Views result shown.');
   }
 
   /**
diff --git a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
index 9fe66be0d5..45d75d64fb 100644
--- a/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
@@ -55,7 +55,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');
@@ -79,7 +79,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.
@@ -117,12 +117,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');
@@ -130,12 +130,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 91d41a760a..30c9114991 100644
--- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
@@ -420,7 +420,7 @@ public function testPagerConfigTranslation() {
     ];
     foreach ($labels as $label => $translation) {
       // Check if we can find the translation.
-      $this->assertRaw($translation);
+      $this->assertSession()->responseContains($translation);
     }
   }
 
@@ -467,7 +467,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()->responseContains($translation);
     }
   }
 
diff --git a/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php b/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php
index a6de0c9b0d..cb98480602 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 cd6b998577..777819708c 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", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
-    $this->assertRaw("test_basetheme_views_post_render", "Views title changed by test_basetheme.test_basetheme_views_post_render");
+    $this->assertSession()->responseContains("test_basetheme_views_pre_render", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
+    $this->assertSession()->responseContains("test_basetheme_views_post_render", "Views title changed by test_basetheme.test_basetheme_views_post_render");
 
     // Make sub theme default to test for hook invocation
     // from both sub and base theme.
@@ -74,13 +74,13 @@ public function testThemedViewPage() {
     // Make sure a views rendered page is touched.
     $this->drupalGet('test_page_display_200');
 
-    $this->assertRaw("test_subtheme_views_pre_render", "Views title changed by test_subtheme.test_subtheme_views_pre_render");
-    $this->assertRaw("test_subtheme_views_post_render", "Views title changed by test_subtheme.test_subtheme_views_post_render");
+    $this->assertSession()->responseContains("test_subtheme_views_pre_render", "Views title changed by test_subtheme.test_subtheme_views_pre_render");
+    $this->assertSession()->responseContains("test_subtheme_views_post_render", "Views title changed by test_subtheme.test_subtheme_views_post_render");
 
-    $this->assertRaw("test_basetheme_views_pre_render", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
-    $this->assertRaw("test_basetheme_views_post_render", "Views title changed by test_basetheme.test_basetheme_views_post_render");
+    $this->assertSession()->responseContains("test_basetheme_views_pre_render", "Views title changed by test_basetheme.test_basetheme_views_pre_render");
+    $this->assertSession()->responseContains("test_basetheme_views_post_render", "Views title changed by test_basetheme.test_basetheme_views_post_render");
 
-    $this->assertRaw('<em class="placeholder">' . count($this->dataSet()) . '</em> items found.', 'Views group title added by test_subtheme.test_subtheme_views_post_render');
+    $this->assertSession()->responseContains('<em class="placeholder">' . count($this->dataSet()) . '</em> items found.', 'Views group title added by test_subtheme.test_subtheme_views_post_render');
   }
 
 }
diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
index acc6a9ca09..f2901486a3 100644
--- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
+++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php
@@ -90,9 +90,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->assertText($view2['page[title]']);
-    $this->assertRaw($node1->toUrl('canonical', ['absolute' => TRUE])->toString());
+    $this->assertSession()->responseContains($node1->toUrl('canonical', ['absolute' => TRUE])->toString());
     $this->assertText($node1->label());
-    $this->assertRaw($node2->toUrl('canonical', ['absolute' => TRUE])->toString());
+    $this->assertSession()->responseContains($node2->toUrl('canonical', ['absolute' => TRUE])->toString());
     $this->assertText($node2->label());
 
     // Go back to the views page and check if this view is there.
@@ -166,7 +166,7 @@ public function testViewsWizardAndListing() {
     $view4['rest_export[create]'] = 1;
     $view4['rest_export[path]'] = $this->randomMachineName(16);
     $this->drupalPostForm('admin/structure/views/add', $view4, t('Save and edit'));
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => $view4['label']]));
+    $this->assertSession()->responseContains(t('The view %view has been saved.', ['%view' => $view4['label']]));
 
     // Check that the REST export path works. JSON will work, as all core
     // formats will be allowed. JSON and XML by default.
diff --git a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
index e50005f49e..a358137a2a 100644
--- a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
@@ -67,7 +67,7 @@ public function testCacheData() {
     $this->assertFieldById('edit-actions-cancel', t('Cancel'));
     // Test we can save the view.
     $this->drupalPostForm('admin/structure/views/view/test_view/edit', [], t('Save'));
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
+    $this->assertSession()->responseContains(t('The view %view has been saved.', ['%view' => 'Test view']));
 
     // Test that a deleted view has no tempstore data.
     $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
index 584fafbfd9..aa43579d50 100644
--- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
@@ -209,7 +209,7 @@ public function testPathDestination() {
     $this->assertLinkByHref('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->assertNoLinkByHref(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 bec61e28d0..2d9d5d90a9 100644
--- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
@@ -91,8 +91,8 @@ public function doPathXssFilterTest() {
     $this->assertEscaped('/<script>alert("hello");</script>');
     $this->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');
   }
 
   /**
@@ -118,7 +118,7 @@ public function testDeleteWithNoPath() {
     $this->drupalPostForm(NULL, [], t('Add Page'));
     $this->drupalPostForm(NULL, [], t('Delete Page'));
     $this->drupalPostForm(NULL, [], t('Save'));
-    $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
+    $this->assertSession()->responseContains(t('The view %view has been saved.', ['%view' => 'Test view']));
   }
 
   /**
diff --git a/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
index eac88e4dd2..a1a0a618fb 100644
--- a/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
@@ -114,8 +114,8 @@ public function testFilterNumericUI() {
 
     $this->drupalPostForm(NULL, [], t('Update preview'));
     // Check the max field label.
-    $this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
-    $this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
+    $this->assertSession()->responseContains('<label for="edit-age-max">And</label>', 'Max field label found');
+    $this->assertSession()->responseContains('<label for="edit-age-min">Age between</label>', 'Min field label found');
     // Check that the description is shown in the right place.
     $this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]->getText()), 'Description of the exposed filter');
   }
diff --git a/core/modules/views_ui/tests/src/Functional/FilterUITest.php b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
index 651ede4d25..2a48b6bb0d 100644
--- a/core/modules/views_ui/tests/src/Functional/FilterUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
@@ -83,7 +83,7 @@ public function testFiltersUI() {
     $this->drupalPostForm(NULL, [], t('Remove group 3'));
 
     // Verify that the group 4 is now named as 3.
-    $this->assertRaw('<span>Group 3</span>', 'Group 3 still exists.');
+    $this->assertSession()->responseContains('<span>Group 3</span>', 'Group 3 still exists.');
 
     // Remove the group 3 again.
     $this->drupalPostForm(NULL, [], t('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 dc2101b817..de72a88cec 100644
--- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php
+++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
@@ -266,7 +266,7 @@ public function testErrorMissingHelp() {
     // description field is shown instead.
     $this->drupalGet('admin/structure/views/nojs/add-handler/test_node_view/default/field');
     $this->assertNoText('Error: missing help');
-    $this->assertRaw('<td class="description"></td>', 'Empty description found');
+    $this->assertSession()->responseContains('<td class="description"></td>', 'Empty description found');
 
     // 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 735c0c4c72..5ec81a1138 100644
--- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php
+++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php
@@ -106,7 +106,7 @@ public function testPreviewUI() {
     $this->assertText(t('Query build time'));
     $this->assertText(t('Query execute time'));
     $this->assertText(t('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
@@ -148,7 +148,7 @@ public function testPreviewAdditionalInfo() {
     $this->assertCount(1, $elements, 'Views Query Preview Info area altered.');
     // 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', 'Attached CSS asset found.');
+    $this->assertSession()->responseContains('css/views_ui_test.test.css', 'Attached CSS asset found.');
   }
 
   /**
diff --git a/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php b/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
index 6dd8003a1e..47aa14e33e 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', 'Title appears correctly');
-    $this->assertRaw('No fields have been used in views yet.', 'No results message appears correctly.');
+    $this->assertSession()->responseContains('Used in views', 'Title appears correctly');
+    $this->assertSession()->responseContains('No fields have been used in views yet.', 'No results message appears correctly.');
 
     // Set up the field_test field.
     $field_storage = FieldStorageConfig::create([
@@ -52,9 +52,9 @@ public function testReportFields() {
 
     $this->drupalGet('admin/reports/fields/views-fields');
     // Assert that the newly created field appears in the overview.
-    $this->assertRaw('<td>field_test</td>', 'Field name appears correctly');
-    $this->assertRaw('>test_field_field_test</a>', 'View name appears correctly');
-    $this->assertRaw('Used in views', 'Title appears correctly');
+    $this->assertSession()->responseContains('<td>field_test</td>', 'Field name appears correctly');
+    $this->assertSession()->responseContains('>test_field_field_test</a>', 'View name appears correctly');
+    $this->assertSession()->responseContains('Used in views', 'Title appears correctly');
   }
 
 }
diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
index c5cef7402c..fedee5d87b 100644
--- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php
@@ -36,7 +36,7 @@ public function testDeleteLink() {
     $this->clickLink(t('Delete view'));
     $this->assertUrl('admin/structure/views/view/test_view/delete');
     $this->drupalPostForm(NULL, [], t('Delete'));
-    $this->assertRaw(t('The view %name has been deleted.', ['%name' => $view->label()]));
+    $this->assertSession()->responseContains(t('The view %name has been deleted.', ['%name' => $view->label()]));
 
     $this->assertUrl('admin/structure/views');
     $view = $this->container->get('entity_type.manager')->getStorage('view')->load('test_view');
diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php
index 2acd63c7bb..d05617e03f 100644
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php
+++ b/core/profiles/standard/tests/src/Functional/StandardTest.php
@@ -95,7 +95,7 @@ public function testStandard() {
     // Add a comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
-    $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
+    $this->assertSession()->responseContains('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
     $this->drupalPostForm(NULL, [
       '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 1461101f05..e30328db6a 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()->responseContains($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->assertNoText('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php
index 916976ad8a..2307d340d3 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()->responseContains($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->assertNoText('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
index c7508811a6..db931ae655 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php
@@ -98,9 +98,9 @@ protected function setUpSettings() {
     $this->assertEqual($direction, 'ltr');
 
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->responseContains($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->assertNoText('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
index 0a0f66f875..04da8e671d 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php
@@ -89,9 +89,9 @@ protected function setUpSettings() {
     $this->assertEqual($direction, 'ltr');
 
     // Verify that the distribution name appears.
-    $this->assertRaw($this->info['distribution']['name']);
+    $this->assertSession()->responseContains($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->assertNoText('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
index 021fbc9a22..cf16593cdb 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerDatabaseErrorMessagesTest.php
@@ -39,7 +39,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 1c8bfb9e5c..968ca1b214 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()->responseContains('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()->responseContains('Drupal already installed');
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php
index 129c2d8d7a..4d33c523a6 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/InstallerNonEnglishProfileWithoutLocaleModuleTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
index ecfe255b94..2fab5115a9 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php
@@ -67,7 +67,7 @@ public function testNonEnglishProfileWithoutLocaleModule() {
 
     // Verify that the confirmation message appears.
     require_once $this->root . '/core/includes/install.inc';
-    $this->assertRaw(t('Congratulations, you installed @drupal!', [
+    $this->assertSession()->responseContains(t('Congratulations, you installed @drupal!', [
       '@drupal' => drupal_install_profile_distribution_name(),
     ]));
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
index 01fb53d92b..4a0a4ca527 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
@@ -25,7 +25,7 @@ public function testInstaller() {
 
     // Verify that the confirmation message appears.
     require_once $this->root . '/core/includes/install.inc';
-    $this->assertRaw(t('Congratulations, you installed @drupal!', [
+    $this->assertSession()->responseContains(t('Congratulations, you installed @drupal!', [
       '@drupal' => drupal_install_profile_distribution_name(),
     ]));
 
@@ -47,8 +47,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->assertEqual('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 fb69ea772d..fbc13705bf 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php
@@ -57,8 +57,8 @@ protected function setUpSettings() {
     parent::setUpSettings();
 
     // Ensure that the error message translation is working.
-    $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.');
 
     // Now do it successfully.
     Database::getConnection('default')->query('DROP TABLE {drupal_install_test}');
@@ -95,7 +95,7 @@ public function testInstaller() {
     $edit = ['preprocess_css' => FALSE];
     $this->drupalPostForm('admin/config/development/performance', $edit, t('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 33bf61f17f..f00d00a4ef 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()->responseContains('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->assertNoText('profile');
 
diff --git a/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php b/core/tests/Drupal/FunctionalTests/Installer/SiteNameTest.php
index 44087f2004..1384bc3268 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, 'The site name that was set during the installation appears on the front page after installation.');
+    $this->assertSession()->responseContains($this->siteName, 'The site name that was set during the installation appears on the front page after installation.');
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/StandardInstallerTest.php
index 48ebb9a801..f15d920155 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()->responseContains('No front page content has been created yet.');
   }
 
   /**
@@ -28,7 +28,7 @@ public function testInstaller() {
   protected function setUpSite() {
     // Test that the correct theme is being used.
     $this->assertNoRaw('bartik');
-    $this->assertRaw('themes/seven/css/theme/install-page.css');
+    $this->assertSession()->responseContains('themes/seven/css/theme/install-page.css');
     parent::setUpSite();
   }
 
@@ -40,7 +40,7 @@ protected function curlExec($curl_options, $redirect = FALSE) {
     // Batch processing happens as part of HTTP redirects, so we can access the
     // HTML of the batch page.
     if (strpos($curl_options[CURLOPT_URL], '&id=1&op=do_nojs') !== FALSE) {
-      $this->assertRaw('themes/classy/css/components/progress.css');
+      $this->assertSession()->responseContains('themes/classy/css/components/progress.css');
     }
     return parent::curlExec($curl_options, $redirect);
   }
