diff --git a/lib/WebDriver/Service/CurlService.php b/lib/WebDriver/Service/CurlService.php index 99af82e..c7b70c1 100755 --- a/lib/WebDriver/Service/CurlService.php +++ b/lib/WebDriver/Service/CurlService.php @@ -50,6 +50,13 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions break; case 'POST': + // Workaround for bug https://bugs.chromium.org/p/chromedriver/issues/detail?id=2943 in Chrome 75. + // Chromedriver now erroneously does not allow POST body to be empty even for the JsonWire protocol. + // If the command POST is empty, here we send some dummy data as a workaround. + // Fix 'borrowed' from https://github.com/facebook/php-webdriver/commit/0f3933c41606fd076d79ff064bc0def2b774e67d#diff-1ee156e0c33356b17f4dc2b3faec69ee. + if (empty($parameters)) { + $parameters = ['_' => '_']; + } if ($parameters && is_array($parameters)) { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters)); } else { diff --git a/lib/WebDriver/WebDriver.php b/lib/WebDriver/WebDriver.php index 0c34dcf..03e2d8d 100644 --- a/lib/WebDriver/WebDriver.php +++ b/lib/WebDriver/WebDriver.php @@ -63,6 +63,13 @@ public function session($requiredCapabilities = Browser::FIREFOX, $desiredCapabi $parameters['requiredCapabilities'] = $requiredCapabilities; } + // Hotfix: W3C WebDriver protocol is not yet supported by php-webdriver, so we must force Chromedriver to + // not use the W3C protocol by default (which is what Chromedriver does starting with version 75). + // Fix 'borrowed' from https://github.com/facebook/php-webdriver/commit/0f3933c41606fd076d79ff064bc0def2b774e67d#diff-1ee156e0c33356b17f4dc2b3faec69ee. + if ($parameters['desiredCapabilities']['browserName'] === Browser::CHROME) { + $parameters['desiredCapabilities']['chromeOptions']['w3c'] = false; + } + $result = $this->curl( 'POST', '/session',