function AssertLegacyTrait::assertField
Same name in other branches
- 8.9.x core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertField()
Asserts that a field exists with the given name or ID.
Parameters
string $field: Name or ID of field to assert.
Deprecated
in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() instead.
See also
https://www.drupal.org/node/3129738
1 call to AssertLegacyTrait::assertField()
- BrowserTestBaseTest::testAssertField in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php - Tests legacy field asserts using textfields.
File
-
core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php, line 342
Class
- AssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\FunctionalTestsCode
protected function assertField($field) {
@trigger_error('AssertLegacyTrait::assertField() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
$xpath = $this->assertSession()
->buildXPathQuery('//textarea[@name=:value]|//input[@name=:value]|//select[@name=:value]', [
':value' => $field,
]) . '|' . $this->assertSession()
->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [
':value' => $field,
]);
$this->assertFieldByXPath($xpath);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.