From 89bf714e26ef964ba8f0b17293883609c1284421 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 9 Feb 2024 15:40:05 +0000 Subject: [PATCH] Use the same method for clearning textareas as input fields --- src/Selenium2Driver.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 6f57e679..058af02c 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -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()) {