Skip to content

Commit c4bdca4

Browse files
author
Sam Minnee
committed
Fix Sauce Connect usage.
Sauce Connect appears to update the sessionId value but not the webdriver.remote.sessionid value when proxying requests from the remote selenium instance to the local proxy. The end result is that, without this patch, php-webdriver can start an initial sesison but guesses the wrong URL for subsequent requests. sessionId in the result seems a more canonical place to get the sesion ID than the webdrive.remote.sessionid key embedded in the value, so this patch amends AbstractWebDriver to pass that through, using webdriver.remote.sessionid as a fail-over, just in case. The change to WebDriver.php is a simple matter of pointing to the right variable.
1 parent 5ff757c commit c4bdca4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,16 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
140140
throw WebDriverException::factory($results['status'], $message);
141141
}
142142

143-
return array('value' => $value, 'info' => $info);
143+
$return = array('value' => $value, 'info' => $info);
144+
145+
// Pass through the sessionId return value if it exists, failing over to webdriver.remote.sessionid in the val
146+
if(isset($results['sessionId'])) {
147+
$return['sessionId'] = $results['sessionId'];
148+
} else if(isset($value['webdriver.remote.sessionid'])) {
149+
$return['sessionId'] = $value['webdriver.remote.sessionid'];
150+
}
151+
152+
return $return;
144153
}
145154

146155
/**

lib/WebDriver/WebDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function session($requiredCapabilities = Browser::FIREFOX, $desiredCapabi
7575
array(CURLOPT_FOLLOWLOCATION => true)
7676
);
7777

78-
if (isset($results['value']['webdriver.remote.sessionid'])) {
79-
return new Session($this->url . '/session/' . $results['value']['webdriver.remote.sessionid']);
78+
if (isset($results['sessionId'])) {
79+
return new Session($this->url . '/session/' . $results['sessionId']);
8080
}
8181

8282
// backward compatibility fallback

0 commit comments

Comments
 (0)