Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion docs/server-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,23 @@ Please note that if you set seleniumAddress, the settings for `seleniumServerJar
Remote Selenium Server
----------------------

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).
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).

**Using TestObject as remote Selenium Server**

In your config file, set these options:
- `testobjectUser` - The username for your TestObject account.
- `testobjectKey` - The key for your TestObject account.

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.

**Using Kobiton as remote Selenium Server**

In your config file, set these options:
- `kobitonUser` - The username for your Kobiton account.
- `kobitonKey` - The API key from your Kobiton account.

Please note that if you set `kobitonUser` and `kobitonKey`, the settings for `browserstackUser`, `browserstackKey`, `seleniumServerJar`, `seleniumPort`, `seleniumArgs`, `sauceUser` and `sauceKey` will be ignored.

**Using BrowserStack as remote Selenium Server**

Expand Down
4 changes: 4 additions & 0 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ let allowedNames = [
'sauceSeleniumAddress',
'browserstackUser',
'browserstackKey',
'kobitonUser',
'kobitonKey',
'testobjectUser',
'testobjectKey',
'directConnect',
'firefoxPath',
'noGlobals',
Expand Down
34 changes: 32 additions & 2 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,37 @@ export interface Config {
*/
sauceSeleniumAddress?: string;

// ---- 4. To use remote browsers via BrowserStack ---------------------------
// ---- 4. To use remote browsers via TestObject ---------------------------

/**
* If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserstackUser,
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
* TestObject.
*/
testobjectUser?: string;
/**
* If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserStackUser,
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
* TestObject.
*/
testobjectKey?: string;

// ---- 5. To use remote browsers via Kobiton ---------------------------

/**
* If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserstackUser,
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
* TestObject.
*/
kobitonUser?: string;
/**
* If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserStackUser,
* browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
* TestObject.
*/
kobitonKey?: string;

// ---- 6. To use remote browsers via BrowserStack ---------------------------

/**
* If browserstackUser and browserstackKey are specified, seleniumServerJar
Expand All @@ -175,7 +205,7 @@ export interface Config {
*/
browserstackKey?: string;

// ---- 5. To connect directly to Drivers ------------------------------------
// ---- 7. To connect directly to Drivers ------------------------------------

/**
* If true, Protractor will connect directly to the browser Drivers
Expand Down
22 changes: 22 additions & 0 deletions lib/driverProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export * from './hosted';
export * from './local';
export * from './mock';
export * from './sauce';
export * from './testObject';
export * from './kobiton';


import {AttachSession} from './attachSession';
Expand All @@ -16,6 +18,8 @@ import {Hosted} from './hosted';
import {Local} from './local';
import {Mock} from './mock';
import {Sauce} from './sauce';
import {TestObject} from './testObject';
import {Kobiton} from './kobiton';

import {Config} from '../config';
import {Logger} from '../logger';
Expand All @@ -36,6 +40,12 @@ export let buildDriverProvider = (config: Config): DriverProvider => {
driverProvider = new Hosted(config);
logWarnings('hosted', config);
}
} else if (config.testobjectUser && config.testobjectKey) {
driverProvider = new TestObject(config);
logWarnings('testObject', config);
} else if (config.kobitonUser && config.kobitonKey) {
driverProvider = new Kobiton(config);
logWarnings('kobiton', config);
} else if (config.browserstackUser && config.browserstackKey) {
driverProvider = new BrowserStack(config);
logWarnings('browserStack', config);
Expand Down Expand Up @@ -69,6 +79,18 @@ export let logWarnings = (providerType: string, config: Config): void => {
if ('attachSession' !== providerType && config.seleniumSessionId) {
warnList.push('seleniumSessionId');
}
if ('testObject' !== providerType && config.testObjectUser) {
warnList.push('testobjectUser');
}
if ('testObject' !== providerType && config.testObjectKey) {
warnList.push('testobjectKey');
}
if ('kobitonUser' !== providerType && config.kobitonUser) {
warnList.push('kobitonUser');
}
if ('kobitonKey' !== providerType && config.kobitonKey) {
warnList.push('kobitonKey');
}
if ('browserStack' !== providerType && config.browserstackUser) {
warnList.push('browserstackUser');
}
Expand Down
34 changes: 34 additions & 0 deletions lib/driverProviders/kobiton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This is an implementation of the Kobiton Driver Provider.
* It is responsible for setting up the account object, tearing
* it down, and setting up the driver correctly.
*/
import * as q from 'q';
import {Config} from '../config';
import {Logger} from '../logger';
import {DriverProvider} from './driverProvider';

let logger = new Logger('kobiton');

export class Kobiton extends DriverProvider {
constructor(config: Config) {
super(config);
}

/**
* Configure and launch (if applicable) the object's environment.
* @return {q.promise} A promise which will resolve when the environment is
* ready to test.
*/
protected setupDriverEnv(): q.Promise<any> {
let deferred = q.defer();
this.config_.capabilities['kobitonUser'] = this.config_.kobitonUser;
this.config_.capabilities['kobitonKey'] = this.config_.kobitonKey;
this.config_.seleniumAddress = 'https://' + this.config_.kobitonUser + ':' +
this.config_.kobitonKey + '@api.kobiton.com/wd/hub';

logger.info('Using Kobiton selenium server at ' + this.config_.seleniumAddress);
deferred.resolve();
return deferred.promise;
}
}
33 changes: 33 additions & 0 deletions lib/driverProviders/testObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This is an implementation of the TestObject Driver Provider.
* It is responsible for setting up the account object, tearing
* it down, and setting up the driver correctly.
*/
import * as q from 'q';
import {Config} from '../config';
import {Logger} from '../logger';
import {DriverProvider} from './driverProvider';

let logger = new Logger('testobject');

export class TestObject extends DriverProvider {
constructor(config: Config) {
super(config);
}

/**
* Configure and launch (if applicable) the object's environment.
* @return {q.promise} A promise which will resolve when the environment is
* ready to test.
*/
protected setupDriverEnv(): q.Promise<any> {
let deferred = q.defer();
this.config_.capabilities['testobject.user'] = this.config_.testobjectUser;
this.config_.capabilities['testobject_api_key'] = this.config_.testobjectKey;
this.config_.seleniumAddress = 'https://us1.appium.testobject.com/wd/hub';

logger.info('Using TestObject selenium server at ' + this.config_.seleniumAddress);
deferred.resolve();
return deferred.promise;
}
}