Skip to content

Commit

Permalink
Merge pull request #149 from stof/fix_select
Browse files Browse the repository at this point in the history
Fix the value for a select without option
  • Loading branch information
stof authored Mar 11, 2020
2 parents e663c4e + 214db60 commit 7ffbd83
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/BrowserKitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 7ffbd83

Please sign in to comment.