From d54611583d56bfbe260132c1f9f90ba7570b12fb Mon Sep 17 00:00:00 2001 From: Abderrahman Daif Date: Sun, 8 Feb 2026 01:30:32 +0100 Subject: [PATCH] Fix W3C WebDriver text format for element value input Replace legacy JSON Wire Protocol format {"value": ["text"]} with W3C-compliant {"text": "string"} in postValue() calls. Selenium 4+ with ChromeDriver requires the W3C format per https://www.w3.org/TR/webdriver2/#element-send-keys This fixes setValue(), attachFile(), and file upload when used with selenium/standalone-chrome containers. --- src/Selenium4Driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Selenium4Driver.php b/src/Selenium4Driver.php index d7af27e6..0a195018 100755 --- a/src/Selenium4Driver.php +++ b/src/Selenium4Driver.php @@ -632,7 +632,7 @@ public function setValue(string $xpath, $value) throw new DriverException('Only string values can be used for a file input.'); } - $element->postValue(array('value' => array(strval($value)))); + $element->postValue(['text' => strval($value)]); return; } @@ -649,7 +649,7 @@ public function setValue(string $xpath, $value) $value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value; } - $element->postValue(array('value' => array($value))); + $element->postValue(['text' => $value]); // Remove the focus from the element if the field still has focus in // order to trigger the change event. By doing this instead of simply // triggering the change event for the given xpath we ensure that the @@ -774,7 +774,7 @@ public function attachFile(string $xpath, string $path) $remotePath = $path; } - $element->postValue(array('value' => array($remotePath))); + $element->postValue(['text' => $remotePath]); } public function isVisible(string $xpath)