Path: blob/trunk/javascript/selenium-webdriver/lib/session.js
2884 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617'use strict'1819const { Capabilities } = require('./capabilities')2021/**22* Contains information about a single WebDriver session.23*/24class Session {25/**26* @param {string} id The session ID.27* @param {!./capabilities.Capabilities} capabilities28* The session capabilities.29*/30constructor(id, capabilities) {31/** @private {string} */32this.id_ = id3334/** @private {!Capabilities} */35this.caps_ =36capabilities instanceof Capabilities37? /** @type {!Capabilities} */ (capabilities)38: new Capabilities(capabilities)39}4041/**42* @return {string} This session's ID.43*/44getId() {45return this.id_46}4748/**49* @return {!Capabilities} This session's capabilities.50*/51getCapabilities() {52return this.caps_53}5455/**56* Retrieves the value of a specific capability.57* @param {string} key The capability to retrieve.58* @return {*} The capability value.59*/60getCapability(key) {61return this.caps_.get(key)62}6364/**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*/69toJSON() {70return this.getId()71}72}7374// PUBLIC API7576module.exports = { Session }777879