public function BrowserTestBaseTest::testAssertFieldById in Drupal 9
Tests legacy field asserts by id and by Xpath.
@group legacy
File
- core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php, line 424
Class
- BrowserTestBaseTest
- Tests BrowserTestBase functionality.
Namespace
Drupal\FunctionalTestsCode
public function testAssertFieldById() {
$this
->expectDeprecation('AssertLegacyTrait::assertFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead. See https://www.drupal.org/node/3129738');
$this
->expectDeprecation('AssertLegacyTrait::assertNoFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals() instead. See https://www.drupal.org/node/3129738');
$this
->expectDeprecation('AssertLegacyTrait::assertFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and check the values directly in the test. See https://www.drupal.org/node/3129738');
$this
->expectDeprecation('AssertLegacyTrait::assertNoFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and assert that the result is empty. See https://www.drupal.org/node/3129738');
$this
->drupalGet('test-field-xpath');
$this
->assertFieldById('edit-save', NULL);
$this
->assertNoFieldById('invalid', NULL);
$this
->assertFieldByXPath("//input[@id = 'edit-name']", 'Test name');
$this
->assertNoFieldByXPath("//input[@id = 'edit-name']", 'wrong value');
}