Skip to content

Commit

Permalink
Merge pull request #405 from aik099/setvalue-checkbox-validation-feat
Browse files Browse the repository at this point in the history
Throw exception, when doing a "setValue" call on checkbox with a non-boolean value
  • Loading branch information
aik099 authored Jan 7, 2025
2 parents 0f020ab + 246de2a commit bedccba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,11 @@ public function setValue(string $xpath, $value)
}

if ('checkbox' === $elementType) {
if ($element->selected() xor (bool) $value) {
if (!is_bool($value)) {
throw new DriverException('Only boolean values can be used for a checkbox input.');
}

if ($element->selected() xor $value) {
$this->clickOnElement($element);
}

Expand Down

0 comments on commit bedccba

Please sign in to comment.