Skip to content

Commit 6bc1f44

Browse files
committed
Backport some fixes from master branch
1 parent 961b121 commit 6bc1f44

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
149149
);
150150
}
151151

152-
if (is_array($result) && !array_key_exists('status', $result) && !isset($result['value']['ready']) && ! isset($result['value']['error'])) {
152+
if (is_array($result) && ! array_key_exists('status', $result) && ! array_key_exists('value', $result)) {
153153
throw WebDriverException::factory(
154154
WebDriverException::CURL_EXEC,
155155
'Payload received from webdriver is valid but unexpected json: ' . substr($rawResult, 0, 1000)
@@ -183,9 +183,12 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
183183

184184
$sessionId = isset($result['sessionId'])
185185
? $result['sessionId']
186-
: (isset($value['webdriver.remote.sessionid'])
187-
? $value['webdriver.remote.sessionid']
188-
: null
186+
: (isset($value['sessionId'])
187+
? $value['sessionId']
188+
: (isset($value['webdriver.remote.sessionid'])
189+
? $value['webdriver.remote.sessionid']
190+
: null
191+
)
189192
);
190193

191194
return array(

lib/WebDriver/Exception.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ abstract class Exception extends \Exception
8686
const UNEXPECTED_PARAMETERS = -5;
8787
const INVALID_REQUEST = -6;
8888
const UNKNOWN_LOCATOR_STRATEGY = -7;
89+
const W3C_WEBDRIVER_ERROR = -8;
8990

9091
private static $errs = array(
9192
// self::SUCCESS => array('Success', 'This should never be thrown!'),
@@ -136,12 +137,8 @@ abstract class Exception extends \Exception
136137
public static function factory($code, $message = null, $previousException = null)
137138
{
138139
// unknown error
139-
if (!isset(self::$errs[$code])) {
140-
if (trim($message) === '') {
141-
$message = 'Unknown Error';
142-
}
143-
144-
return new \Exception($message, $code, $previousException);
140+
if (! isset(self::$errs[$code])) {
141+
$code = self::UNKNOWN_ERROR;
145142
}
146143

147144
$errorDefinition = self::$errs[$code];
@@ -150,6 +147,10 @@ public static function factory($code, $message = null, $previousException = null
150147
$message = $errorDefinition[1];
151148
}
152149

150+
if (! is_numeric($code)) {
151+
$code = self::W3C_WEBDRIVER_ERROR;
152+
}
153+
153154
$className = __CLASS__ . '\\' . $errorDefinition[0];
154155

155156
return new $className($message, $code, $previousException);

0 commit comments

Comments
 (0)