forked from angular/protractor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathattachSession.ts
52 lines (45 loc) · 1.58 KB
/
attachSession.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* This is an implementation of the Attach Session Driver Provider.
* It is responsible for setting up the account object, tearing
* it down, and setting up the driver correctly.
*/
import {Session, WebDriver} from 'selenium-webdriver';
import {Executor, HttpClient} from 'selenium-webdriver/http';
import {Config} from '../config';
import {Logger} from '../logger';
import {DriverProvider} from './driverProvider';
let logger = new Logger('attachSession');
export class AttachSession extends DriverProvider {
constructor(config: Config) {
super(config);
}
/**
* Configure and launch (if applicable) the object's environment.
* @return {Promise} A promise which will resolve when the environment is
* ready to test.
*/
protected async setupDriverEnv(): Promise<any> {
logger.info('Using the selenium server at ' + this.config_.seleniumAddress);
logger.info('Using session id - ' + this.config_.seleniumSessionId);
}
/**
* Getting a new driver by attaching an existing session.
*
* @public
* @return {WebDriver} webdriver instance
*/
async getNewDriver(): Promise<WebDriver> {
const httpClient: HttpClient = new HttpClient(this.config_.seleniumAddress);
const executor: Executor = new Executor(httpClient);
const session: Session = new Session(this.config_.seleniumSessionId, null);
const newDriver = new WebDriver(session, executor);
this.drivers_.push(newDriver);
return newDriver;
}
/**
* Maintains the existing session and does not quit the driver.
*
* @public
*/
async quitDriver(): Promise<void> {}
}