function BrowserKitDriver::getValue
Overrides CoreDriver::getValue
File
-
vendor/
behat/ mink-browserkit-driver/ src/ BrowserKitDriver.php, line 377
Class
- BrowserKitDriver
- Symfony BrowserKit driver.
Namespace
Behat\Mink\DriverCode
public function getValue(string $xpath) {
if (in_array($this->getAttribute($xpath, 'type'), array(
'submit',
'image',
'button',
), true)) {
return $this->getAttribute($xpath, 'value');
}
$node = $this->getCrawlerNode($this->getFilteredCrawler($xpath));
if ('option' === $node->tagName) {
return $this->getOptionValue($node);
}
try {
$field = $this->getFormField($xpath);
} catch (\InvalidArgumentException $e) {
return $this->getAttribute($xpath, 'value');
}
$value = $field->getValue();
if ('select' === $node->tagName && null === $value) {
// symfony/dom-crawler returns null as value for a non-multiple select without
// options but we want an empty string to match browsers.
$value = '';
}
return $value;
}