You are here

protected function AssertLegacyTrait::assertField in Drupal 9

Same name and namespace in other branches
  1. 8 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 343

Class

AssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\FunctionalTests

Code

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