function BrowserKitDriver::isChecked
Overrides CoreDriver::isChecked
File
-
vendor/
behat/ mink-browserkit-driver/ src/ BrowserKitDriver.php, line 507
Class
- BrowserKitDriver
- Symfony BrowserKit driver.
Namespace
Behat\Mink\DriverCode
public function isChecked(string $xpath) {
$field = $this->getFormField($xpath);
if (!$field instanceof ChoiceFormField || 'select' === $field->getType()) {
throw new DriverException(sprintf('Impossible to get the checked state of the element with XPath "%s" as it is not a checkbox or radio input', $xpath));
}
if ('checkbox' === $field->getType()) {
return $field->hasValue();
}
$radio = $this->getCrawlerNode($this->getFilteredCrawler($xpath));
return $radio->getAttribute('value') === $field->getValue();
}