2016-01-30 08:50:46 -08:00
|
|
|
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
|
// distributed with this work for additional information
|
|
|
|
|
// regarding copyright ownership. The SFC licenses this file
|
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
|
// "License"); you may not use this file except in compliance
|
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing,
|
|
|
|
|
// software distributed under the License is distributed on an
|
|
|
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
// KIND, either express or implied. See the License for the
|
|
|
|
|
// specific language governing permissions and limitations
|
|
|
|
|
// under the License.
|
|
|
|
|
|
2020-08-03 17:56:31 +03:00
|
|
|
'use strict'
|
2016-01-30 08:50:46 -08:00
|
|
|
|
2020-08-03 17:56:31 +03:00
|
|
|
const { Capabilities } = require('./capabilities')
|
2016-01-30 08:50:46 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Contains information about a single WebDriver session.
|
|
|
|
|
*/
|
|
|
|
|
class Session {
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} id The session ID.
|
2018-01-13 09:23:57 -08:00
|
|
|
* @param {!./capabilities.Capabilities} capabilities
|
|
|
|
|
* The session capabilities.
|
2016-01-30 08:50:46 -08:00
|
|
|
*/
|
|
|
|
|
constructor(id, capabilities) {
|
|
|
|
|
/** @private {string} */
|
2020-08-03 17:56:31 +03:00
|
|
|
this.id_ = id
|
2016-01-30 08:50:46 -08:00
|
|
|
|
|
|
|
|
/** @private {!Capabilities} */
|
2020-08-03 17:56:31 +03:00
|
|
|
this.caps_ =
|
|
|
|
|
capabilities instanceof Capabilities
|
|
|
|
|
? /** @type {!Capabilities} */ (capabilities)
|
|
|
|
|
: new Capabilities(capabilities)
|
2016-01-30 08:50:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return {string} This session's ID.
|
|
|
|
|
*/
|
|
|
|
|
getId() {
|
2020-08-03 17:56:31 +03:00
|
|
|
return this.id_
|
2016-01-30 08:50:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return {!Capabilities} This session's capabilities.
|
|
|
|
|
*/
|
|
|
|
|
getCapabilities() {
|
2020-08-03 17:56:31 +03:00
|
|
|
return this.caps_
|
2016-01-30 08:50:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retrieves the value of a specific capability.
|
|
|
|
|
* @param {string} key The capability to retrieve.
|
|
|
|
|
* @return {*} The capability value.
|
|
|
|
|
*/
|
|
|
|
|
getCapability(key) {
|
2020-08-03 17:56:31 +03:00
|
|
|
return this.caps_.get(key)
|
2016-01-30 08:50:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the JSON representation of this object, which is just the string
|
|
|
|
|
* session ID.
|
|
|
|
|
* @return {string} The JSON representation of this Session.
|
|
|
|
|
*/
|
|
|
|
|
toJSON() {
|
2020-08-03 17:56:31 +03:00
|
|
|
return this.getId()
|
2016-01-30 08:50:46 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PUBLIC API
|
|
|
|
|
|
2021-11-27 11:13:27 -05:00
|
|
|
module.exports = { Session }
|