protected function ViewTestBase::helperButtonHasLabel in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel()
- 9 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel()
Asserts the existence of a button with a certain ID and label.
Parameters
string $id: The HTML ID of the button
string $expected_label: The expected label for the button.
string $message: (optional) A custom message to display with the assertion. If no custom message is provided, the message will indicate the button label.
Throws
\Behat\Mink\Exception\ElementNotFoundException
File
- core/
modules/ views/ tests/ src/ Functional/ ViewTestBase.php, line 101
Class
- ViewTestBase
- Defines a base class for Views testing in the full web test environment.
Namespace
Drupal\Tests\views\FunctionalCode
protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
$xpath = $this
->assertSession()
->buildXPathQuery('//button[@id=:value]|//input[@id=:value]', [
':value' => $id,
]);
$field = $this
->getSession()
->getPage()
->find('xpath', $xpath);
if (empty($field)) {
throw new ElementNotFoundException($this
->getSession()
->getDriver(), 'form field', 'id', $field);
}
$this
->assertEquals($expected_label, $field
->getValue());
}