@@ -142,7 +142,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
142142 );
143143 }
144144
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 ' ]) ) {
146146 throw WebDriverException::factory (
147147 WebDriverException::CURL_EXEC ,
148148 '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
153153 $ message = (is_array ($ value ) && array_key_exists ('message ' , $ value )) ? $ value ['message ' ] : null ;
154154
155155 // 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+ );
158175 }
159176
160177 $ sessionId = isset ($ result ['sessionId ' ])
0 commit comments