You are here

protected function AssertContentTrait::constructFieldXpath in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  2. 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()

Helper: Constructs an XPath for the given set of attributes and value.

Parameters

string $attribute: Field attributes.

string $value: Value of field.

Return value

string XPath for specified values.

File

core/tests/Drupal/KernelTests/AssertContentTrait.php, line 1472

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\KernelTests

Code

protected function constructFieldXpath($attribute, $value) {
  $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]';
  return $this
    ->buildXPathQuery($xpath, [
    ':value' => $value,
  ]);
}