Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WebAssert.php

function WebAssert::pageTextContains

Checks that current page contains text.

Parameters

string $text:

Return value

void

Throws

ResponseTextException

File

vendor/behat/mink/src/WebAssert.php, line 286

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function pageTextContains(string $text) {
    $actual = $this->session
        ->getPage()
        ->getText();
    $actual = preg_replace('/\\s+/u', ' ', $actual) ?? $actual;
    $regex = '/' . preg_quote($text, '/') . '/ui';
    $message = sprintf('The text "%s" was not found anywhere in the text of the current page.', $text);
    $this->assertResponseText((bool) preg_match($regex, $actual), $message);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal