Skip to content

Commit

Permalink
Support ChromeDriver's new way of returning sessionIds
Browse files Browse the repository at this point in the history
  • Loading branch information
chibimagic committed Aug 13, 2013
1 parent a67b2f3 commit c66282b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions WebDriver/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ protected function __construct($server_url, $capabilities) {
$response = $this->execute("POST", "/session", $payload);

// Parse out session id
$matches = array();
preg_match("/Location:.*\/(.*)/", $response['header'], $matches);
PHPUnit_Framework_Assert::assertEquals(2, count($matches), "Did not get a session id from $server_url\n" . print_r($response, true));
$this->session_id = trim($matches[1]);
if (count($matches) === 2) {
$this->session_id = trim($matches[1]);
} else {
// The new Chrome driver returns the session id in the body instead
$this->session_id = WebDriver::GetJSONValue($response, "webdriver.remote.sessionid");
}
PHPUnit_Framework_Assert::assertNotNull($this->session_id, "Did not get a session id from $server_url\n" . print_r($response, true));
}

public static function InitAtSauce($sauce_username, $sauce_key, $os, $browser, $version = false, $additional_options = array()) {
Expand Down

0 comments on commit c66282b

Please sign in to comment.