@@ -142,7 +142,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
142
142
);
143
143
}
144
144
145
- if (is_array ($ result ) && !array_key_exists ('status ' , $ result )) {
145
+ if (is_array ($ result ) && !array_key_exists ('status ' , $ result ) && ! isset ( $ result [ ' value ' ][ ' ready ' ]) && ! isset ( $ result [ ' value ' ][ ' error ' ]) ) {
146
146
throw WebDriverException::factory (
147
147
WebDriverException::CURL_EXEC ,
148
148
'Payload received from webdriver is valid but unexpected json: ' . substr ($ rawResult , 0 , 1000 )
@@ -153,8 +153,25 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
153
153
$ message = (is_array ($ value ) && array_key_exists ('message ' , $ value )) ? $ value ['message ' ] : null ;
154
154
155
155
// if not success, throw exception
156
- if ((int ) $ result ['status ' ] !== 0 ) {
157
- throw WebDriverException::factory ($ result ['status ' ], $ message );
156
+ if (isset ($ result ['status ' ]) && (int ) $ result ['status ' ] !== 0 ) {
157
+ throw WebDriverException::factory (
158
+ $ result ['status ' ],
159
+ 'WebDriver response "status" '
160
+ );
161
+ }
162
+
163
+ if (isset ($ value ['error ' ])) {
164
+ throw WebDriverException::factory (
165
+ $ value ['error ' ],
166
+ $ message ?: 'WebDriver response "error" '
167
+ );
168
+ }
169
+
170
+ if (isset ($ value ['ready ' ]) && $ value ['ready ' ] !== true ) {
171
+ throw WebDriverException::factory (
172
+ WebDriverException::CURL_EXEC ,
173
+ $ message ?: 'WebDriver session not "ready" '
174
+ );
158
175
}
159
176
160
177
$ sessionId = isset ($ result ['sessionId ' ])
0 commit comments