Skip to content

Commit

Permalink
Merge pull request #4 from Lullabot/justafish/fix-textarea
Browse files Browse the repository at this point in the history
Use the same method for clearning textareas as input fields
  • Loading branch information
justafish authored Feb 12, 2024
2 parents 5566e3f + 89bf714 commit 5f9ecc2
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,21 +743,13 @@ public function setValue(string $xpath, $value)
$value = strval($value);

if (in_array($elementName, array('input', 'textarea'))) {
if ($this->isW3C() && $elementName === 'textarea') {
// Backspace doesn't work for textareas for some reason, and
// sending ->clear() will trigger a change event.
$element->postValue(array('text' => Key::CONTROL . 'a'));
$element->postValue(array('text' => Key::DELETE));
}
else {
if ($this->isW3C()) {
$existingValueLength = strlen($element->property('value'));
}
else {
$existingValueLength = strlen($element->attribute('value'));
}
$value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value;
}
if ($this->isW3C()) {
$existingValueLength = strlen($element->property('value'));
}
else {
$existingValueLength = strlen($element->attribute('value'));
}
$value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value;
}

if ($this->isW3C()) {
Expand Down

0 comments on commit 5f9ecc2

Please sign in to comment.