# lib/webdriver/session.js

    1// Copyright 2011 Software Freedom Conservancy. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7//      http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.1415goog.provide('webdriver.Session');1617goog.require('webdriver.Capabilities');18192021/**22 * Contains information about a WebDriver session.23 * @param {string} id The session ID.24 * @param {!(Object|webdriver.Capabilities)} capabilities The session25 *     capabilities.26 * @constructor27 */28webdriver.Session = function(id, capabilities) {2930  /** @private {string} */31  this.id_ = id;3233  /** @private {!webdriver.Capabilities} */34  this.caps_ = new webdriver.Capabilities().merge(capabilities);35};363738/**39 * @return {string} This session's ID.40 */41webdriver.Session.prototype.getId = function() {42  return this.id_;43};444546/**47 * @return {!webdriver.Capabilities} This session's capabilities.48 */49webdriver.Session.prototype.getCapabilities = function() {50  return this.caps_;51};525354/**55 * Retrieves the value of a specific capability.56 * @param {string} key The capability to retrieve.57 * @return {*} The capability value.58 */59webdriver.Session.prototype.getCapability = function(key) {60  return this.caps_.get(key);61};626364/**65 * Returns the JSON representation of this object, which is just the string66 * session ID.67 * @return {string} The JSON representation of this Session.68 */69webdriver.Session.prototype.toJSON = function() {70  return this.getId();71};