diff --git a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
index 4d1906e..14de8fe 100644
--- a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
@@ -33,6 +33,11 @@ public function testGoTo() {
     // Test page contains some text.
     $this->assertSession()->pageTextContains('Test page text.');
 
+    // Check that returned plain text is correct.
+    $text = $this->getTextContent();
+    $this->assertNotContains('Test page text.', $text);
+    $this->assertContains('</html>', $text);
+
     // Response includes cache tags that we can assert.
     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Tags', 'rendered');
 
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 6a8b150..3767ad1 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -1613,7 +1613,7 @@ protected function clickLink($label) {
    * Retrieves the plain-text content from the current page.
    */
   protected function getTextContent() {
-    return $this->getSession()->getPage()->getContent();
+    return $this->getSession()->getPage()->getText();
   }
 
   /**
