function AssertContentTrait::constructFieldXpath

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  2. 10 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  3. 8.9.x 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 1481

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,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.