diff --git a/src/BrowserKitDriver.php b/src/BrowserKitDriver.php index b03e6d3..0f96778 100644 --- a/src/BrowserKitDriver.php +++ b/src/BrowserKitDriver.php @@ -425,7 +425,15 @@ public function getValue($xpath) return $this->getAttribute($xpath, 'value'); } - return $field->getValue(); + $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; } /**