Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 6ba30e0

Browse files
lt-bstevensqiyigg
authored andcommitted
feat(driverProviders): Add TestObject and Kobiton as driverProviders
feat(driverProviders): Add TestObject and Kobiton as driverProviders 1. Add testObject and kobiton to driverProviders 2. Add testObject and kobiton items to cli, config and index 3. Add instructions for using testObject and kobiton to server-setup
1 parent 83e2ba8 commit 6ba30e0

File tree

6 files changed

+142
-3
lines changed

6 files changed

+142
-3
lines changed

Diff for: docs/server-setup.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,23 @@ Please note that if you set seleniumAddress, the settings for `seleniumServerJar
6161
Remote Selenium Server
6262
----------------------
6363

64-
To run your tests against a remote Selenium Server, you will need an account with a service that hosts the server (and the browser drivers). Protractor has built in support for [BrowserStack](https://www.browserstack.com) and [Sauce Labs](http://www.saucelabs.com).
64+
To run your tests against a remote Selenium Server, you will need an account with a service that hosts the server (and the browser drivers). Protractor has built in support for [BrowserStack](https://www.browserstack.com) , [Sauce Labs](http://www.saucelabs.com) and [TestObject](https://www.testobject.com).
65+
66+
**Using TestObject as remote Selenium Server**
67+
68+
In your config file, set these options:
69+
- `testobjectUser` - The username for your TestObject account.
70+
- `testobjectKey` - The key for your TestObject account.
71+
72+
Please note that if you set `testobjectUser` and `testobjectKey`, the settings for `kobitonUser`, `kobitonKey`, `browserstackUser`, `browserstackKey`, `seleniumServerJar`, `seleniumPort`, `seleniumArgs`, `sauceUser` and `sauceKey` will be ignored.
73+
74+
**Using Kobiton as remote Selenium Server**
75+
76+
In your config file, set these options:
77+
- `kobitonUser` - The username for your Kobiton account.
78+
- `kobitonKey` - The API key from your Kobiton account.
79+
80+
Please note that if you set `kobitonUser` and `kobitonKey`, the settings for `browserstackUser`, `browserstackKey`, `seleniumServerJar`, `seleniumPort`, `seleniumArgs`, `sauceUser` and `sauceKey` will be ignored.
6581

6682
**Using BrowserStack as remote Selenium Server**
6783

Diff for: lib/cli.ts

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ let allowedNames = [
5050
'sauceSeleniumAddress',
5151
'browserstackUser',
5252
'browserstackKey',
53+
'kobitonUser',
54+
'kobitonKey',
55+
'testobjectUser',
56+
'testobjectKey',
5357
'directConnect',
5458
'firefoxPath',
5559
'noGlobals',

Diff for: lib/config.ts

+32-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,37 @@ export interface Config {
162162
*/
163163
sauceSeleniumAddress?: string;
164164

165-
// ---- 4. To use remote browsers via BrowserStack ---------------------------
165+
// ---- 4. To use remote browsers via TestObject ---------------------------
166+
167+
/**
168+
* If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserstackUser,
169+
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
170+
* TestObject.
171+
*/
172+
testobjectUser?: string;
173+
/**
174+
* If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserStackUser,
175+
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
176+
* TestObject.
177+
*/
178+
testobjectKey?: string;
179+
180+
// ---- 5. To use remote browsers via Kobiton ---------------------------
181+
182+
/**
183+
* If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserstackUser,
184+
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
185+
* TestObject.
186+
*/
187+
kobitonUser?: string;
188+
/**
189+
* If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserStackUser,
190+
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
191+
* TestObject.
192+
*/
193+
kobitonKey?: string;
194+
195+
// ---- 6. To use remote browsers via BrowserStack ---------------------------
166196

167197
/**
168198
* If browserstackUser and browserstackKey are specified, seleniumServerJar
@@ -175,7 +205,7 @@ export interface Config {
175205
*/
176206
browserstackKey?: string;
177207

178-
// ---- 5. To connect directly to Drivers ------------------------------------
208+
// ---- 7. To connect directly to Drivers ------------------------------------
179209

180210
/**
181211
* If true, Protractor will connect directly to the browser Drivers

Diff for: lib/driverProviders/index.ts

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export * from './hosted';
66
export * from './local';
77
export * from './mock';
88
export * from './sauce';
9+
export * from './testObject';
10+
export * from './kobiton';
911

1012

1113
import {AttachSession} from './attachSession';
@@ -16,6 +18,8 @@ import {Hosted} from './hosted';
1618
import {Local} from './local';
1719
import {Mock} from './mock';
1820
import {Sauce} from './sauce';
21+
import {TestObject} from './testObject';
22+
import {Kobiton} from './kobiton';
1923

2024
import {Config} from '../config';
2125
import {Logger} from '../logger';
@@ -36,6 +40,12 @@ export let buildDriverProvider = (config: Config): DriverProvider => {
3640
driverProvider = new Hosted(config);
3741
logWarnings('hosted', config);
3842
}
43+
} else if (config.testobjectUser && config.testobjectKey) {
44+
driverProvider = new TestObject(config);
45+
logWarnings('testObject', config);
46+
} else if (config.kobitonUser && config.kobitonKey) {
47+
driverProvider = new Kobiton(config);
48+
logWarnings('kobiton', config);
3949
} else if (config.browserstackUser && config.browserstackKey) {
4050
driverProvider = new BrowserStack(config);
4151
logWarnings('browserStack', config);
@@ -69,6 +79,18 @@ export let logWarnings = (providerType: string, config: Config): void => {
6979
if ('attachSession' !== providerType && config.seleniumSessionId) {
7080
warnList.push('seleniumSessionId');
7181
}
82+
if ('testObject' !== providerType && config.testObjectUser) {
83+
warnList.push('testobjectUser');
84+
}
85+
if ('testObject' !== providerType && config.testObjectKey) {
86+
warnList.push('testobjectKey');
87+
}
88+
if ('kobitonUser' !== providerType && config.kobitonUser) {
89+
warnList.push('kobitonUser');
90+
}
91+
if ('kobitonKey' !== providerType && config.kobitonKey) {
92+
warnList.push('kobitonKey');
93+
}
7294
if ('browserStack' !== providerType && config.browserstackUser) {
7395
warnList.push('browserstackUser');
7496
}

Diff for: lib/driverProviders/kobiton.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This is an implementation of the Kobiton Driver Provider.
3+
* It is responsible for setting up the account object, tearing
4+
* it down, and setting up the driver correctly.
5+
*/
6+
import * as q from 'q';
7+
import {Config} from '../config';
8+
import {Logger} from '../logger';
9+
import {DriverProvider} from './driverProvider';
10+
11+
let logger = new Logger('kobiton');
12+
13+
export class Kobiton extends DriverProvider {
14+
constructor(config: Config) {
15+
super(config);
16+
}
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+
protected setupDriverEnv(): q.Promise<any> {
24+
let deferred = q.defer();
25+
this.config_.capabilities['kobitonUser'] = this.config_.kobitonUser;
26+
this.config_.capabilities['kobitonKey'] = this.config_.kobitonKey;
27+
this.config_.seleniumAddress = 'https://' + this.config_.kobitonUser + ':' +
28+
this.config_.kobitonKey + '@api.kobiton.com/wd/hub';
29+
30+
logger.info('Using Kobiton selenium server at ' + this.config_.seleniumAddress);
31+
deferred.resolve();
32+
return deferred.promise;
33+
}
34+
}

Diff for: lib/driverProviders/testObject.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This is an implementation of the TestObject Driver Provider.
3+
* It is responsible for setting up the account object, tearing
4+
* it down, and setting up the driver correctly.
5+
*/
6+
import * as q from 'q';
7+
import {Config} from '../config';
8+
import {Logger} from '../logger';
9+
import {DriverProvider} from './driverProvider';
10+
11+
let logger = new Logger('testobject');
12+
13+
export class TestObject extends DriverProvider {
14+
constructor(config: Config) {
15+
super(config);
16+
}
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+
protected setupDriverEnv(): q.Promise<any> {
24+
let deferred = q.defer();
25+
this.config_.capabilities['testobject.user'] = this.config_.testobjectUser;
26+
this.config_.capabilities['testobject_api_key'] = this.config_.testobjectKey;
27+
this.config_.seleniumAddress = 'https://us1.appium.testobject.com/wd/hub';
28+
29+
logger.info('Using TestObject selenium server at ' + this.config_.seleniumAddress);
30+
deferred.resolve();
31+
return deferred.promise;
32+
}
33+
}

0 commit comments

Comments
 (0)