public function BrowserTestBaseTest::testFieldAssertsForButton in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testFieldAssertsForButton()
- 9 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testFieldAssertsForButton()
Tests legacy field asserts for button field type.
File
- core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php, line 416
Class
- BrowserTestBaseTest
- Tests BrowserTestBase functionality.
Namespace
Drupal\FunctionalTestsCode
public function testFieldAssertsForButton() {
$this
->drupalGet('test-field-xpath');
// Verify if the test passes with button ID.
$this
->assertSession()
->buttonExists('edit-save');
// Verify if the test passes with button Value.
$this
->assertSession()
->buttonExists('Save');
// Verify if the test passes with button Name.
$this
->assertSession()
->buttonExists('op');
// Verify if the test passes with button ID.
$this
->assertSession()
->buttonNotExists('i-do-not-exist');
// Verify if the test passes with button Value.
$this
->assertSession()
->buttonNotExists('I do not exist');
// Verify if the test passes with button Name.
$this
->assertSession()
->buttonNotExists('no');
// Test that multiple fields with the same name are validated correctly.
$this
->assertSession()
->buttonExists('duplicate_button');
$this
->assertSession()
->buttonExists('Duplicate button 1');
$this
->assertSession()
->buttonExists('Duplicate button 2');
$this
->assertSession()
->buttonNotExists('Rabbit');
try {
$this
->assertSession()
->buttonNotExists('Duplicate button 2');
$this
->fail('The "duplicate_button" field with the value Duplicate button 2 was not found.');
} catch (ExpectationException $e) {
// Expected exception; just continue testing.
}
}