Skip to content

Commit

Permalink
Fix Sauce Connect usage.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sam Minnee committed Oct 4, 2013
1 parent 5ff757c commit c4bdca4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/WebDriver/AbstractWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,16 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
throw WebDriverException::factory($results['status'], $message);
}

return array('value' => $value, 'info' => $info);
$return = array('value' => $value, 'info' => $info);

// Pass through the sessionId return value if it exists, failing over to webdriver.remote.sessionid in the val
if(isset($results['sessionId'])) {
$return['sessionId'] = $results['sessionId'];
} else if(isset($value['webdriver.remote.sessionid'])) {
$return['sessionId'] = $value['webdriver.remote.sessionid'];
}

return $return;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/WebDriver/WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function session($requiredCapabilities = Browser::FIREFOX, $desiredCapabi
array(CURLOPT_FOLLOWLOCATION => true)
);

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

// backward compatibility fallback
Expand Down

0 comments on commit c4bdca4

Please sign in to comment.