function BrowserTestBaseTest::testFieldAssertsForButton
Same name in other branches
- 8.9.x 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 608
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.
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.