UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/*
4 * This is an implementation of the Attach Session Driver Provider.
5 * It is responsible for setting up the account object, tearing
6 * it down, and setting up the driver correctly.
7 */
8const q = require("q");
9const selenium_webdriver_1 = require("selenium-webdriver");
10const logger_1 = require("../logger");
11const driverProvider_1 = require("./driverProvider");
12const http = require('selenium-webdriver/http');
13let logger = new logger_1.Logger('attachSession');
14class AttachSession extends driverProvider_1.DriverProvider {
15 constructor(config) {
16 super(config);
17 }
18 /**
19 * Configure and launch (if applicable) the object's environment.
20 * @return {q.promise} A promise which will resolve when the environment is
21 * ready to test.
22 */
23 setupDriverEnv() {
24 logger.info('Using the selenium server at ' + this.config_.seleniumAddress);
25 logger.info('Using session id - ' + this.config_.seleniumSessionId);
26 return q(undefined);
27 }
28 /**
29 * Getting a new driver by attaching an existing session.
30 *
31 * @public
32 * @return {WebDriver} webdriver instance
33 */
34 getNewDriver() {
35 const httpClient = new http.HttpClient(this.config_.seleniumAddress);
36 const executor = new http.Executor(httpClient);
37 const newDriver = selenium_webdriver_1.WebDriver.attachToSession(executor, this.config_.seleniumSessionId);
38 this.drivers_.push(newDriver);
39 return newDriver;
40 }
41 /**
42 * Maintains the existing session and does not quit the driver.
43 *
44 * @public
45 */
46 quitDriver() {
47 return selenium_webdriver_1.promise.when(undefined);
48 }
49}
50exports.AttachSession = AttachSession;
51//# sourceMappingURL=attachSession.js.map
\No newline at end of file