@@ -215,7 +215,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
215
215
);
216
216
}
217
217
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 ' ]) ) {
219
219
throw WebDriverException::factory (
220
220
WebDriverException::CURL_EXEC ,
221
221
'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
226
226
$ message = (is_array ($ value ) && array_key_exists ('message ' , $ value )) ? $ value ['message ' ] : null ;
227
227
228
228
// 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
+ );
231
248
}
232
249
233
250
$ sessionId = isset ($ result ['sessionId ' ])
0 commit comments