@@ -215,7 +215,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
215215 );
216216 }
217217
218- if (is_array ($ result ) && ! array_key_exists ('status ' , $ result )) {
218+ if (is_array ($ result ) && ! array_key_exists ('status ' , $ result ) && ! isset ( $ result [ ' value ' ][ ' ready ' ]) && ! isset ( $ result [ ' value ' ][ ' error ' ]) ) {
219219 throw WebDriverException::factory (
220220 WebDriverException::CURL_EXEC ,
221221 'Payload received from webdriver is valid but unexpected json: ' . substr ($ rawResult , 0 , 1000 )
@@ -226,8 +226,25 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
226226 $ message = (is_array ($ value ) && array_key_exists ('message ' , $ value )) ? $ value ['message ' ] : null ;
227227
228228 // if not success, throw exception
229- if ((int ) $ result ['status ' ] !== 0 ) {
230- throw WebDriverException::factory ($ result ['status ' ], $ message );
229+ if (isset ($ result ['status ' ]) && (int ) $ result ['status ' ] !== 0 ) {
230+ throw WebDriverException::factory (
231+ $ result ['status ' ],
232+ 'WebDriver response "status" '
233+ );
234+ }
235+
236+ if (isset ($ value ['error ' ])) {
237+ throw WebDriverException::factory (
238+ $ value ['error ' ],
239+ $ message ?: 'WebDriver response "error" '
240+ );
241+ }
242+
243+ if (isset ($ value ['ready ' ]) && $ value ['ready ' ] !== true ) {
244+ throw WebDriverException::factory (
245+ WebDriverException::CURL_EXEC ,
246+ $ message ?: 'WebDriver session not "ready" '
247+ );
231248 }
232249
233250 $ sessionId = isset ($ result ['sessionId ' ])
0 commit comments