function AssertLegacyTrait::constructFieldXpath

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::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.

Deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead.

11 calls to AssertLegacyTrait::constructFieldXpath()
AssertLegacyTrait::assertField in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field exists with the given name or ID.
AssertLegacyTrait::assertFieldById in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field exists with the given ID and value.
AssertLegacyTrait::assertFieldByName in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field exists with the given name and value.
AssertLegacyTrait::assertNoField in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field does NOT exist with the given name or ID.
AssertLegacyTrait::assertNoFieldById in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
Asserts that a field does not exist with the given ID and value.

... See full list

File

core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php, line 803

Class

AssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\FunctionalTests

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.