diff --git a/docs/server-setup.md b/docs/server-setup.md index e9dfb36c8..296722d2f 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -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** diff --git a/lib/cli.ts b/lib/cli.ts index 0964e0c1e..c62f3cee8 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -50,6 +50,10 @@ let allowedNames = [ 'sauceSeleniumAddress', 'browserstackUser', 'browserstackKey', + 'kobitonUser', + 'kobitonKey', + 'testobjectUser', + 'testobjectKey', 'directConnect', 'firefoxPath', 'noGlobals', diff --git a/lib/config.ts b/lib/config.ts index 21b34d8eb..e07981361 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -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 @@ -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 diff --git a/lib/driverProviders/index.ts b/lib/driverProviders/index.ts index 40e066a8e..25fcabcf6 100644 --- a/lib/driverProviders/index.ts +++ b/lib/driverProviders/index.ts @@ -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'; @@ -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'; @@ -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); @@ -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'); } diff --git a/lib/driverProviders/kobiton.ts b/lib/driverProviders/kobiton.ts new file mode 100644 index 000000000..8bfc53ddc --- /dev/null +++ b/lib/driverProviders/kobiton.ts @@ -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 { + 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; + } +} diff --git a/lib/driverProviders/testObject.ts b/lib/driverProviders/testObject.ts new file mode 100644 index 000000000..9e0a4266f --- /dev/null +++ b/lib/driverProviders/testObject.ts @@ -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 { + 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; + } +}