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

Breadcrumb

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

function WebAssert::elementAttributeContains

Checks that an attribute of a specific elements contains text.

Parameters

string $selectorType:

string|array $selector:

string $attribute:

string $text:

Return value

void

Throws

ElementHtmlException

ElementNotFoundException

File

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

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function elementAttributeContains(string $selectorType, $selector, string $attribute, string $text) {
    $element = $this->elementAttributeExists($selectorType, $selector, $attribute);
    $actual = (string) $element->getAttribute($attribute);
    $regex = '/' . preg_quote($text, '/') . '/ui';
    $message = sprintf('The text "%s" was not found in the attribute "%s" of the %s.', $text, $attribute, $this->getMatchingElementRepresentation($selectorType, $selector));
    $this->assertElement((bool) preg_match($regex, $actual), $message, $element);
}

API Navigation

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