diff --git a/docs/server-setup.md b/docs/server-setup.md index e9dfb36c8..45f0cbaa7 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -61,7 +61,7 @@ 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 [Perfecto](http://www.perfecto.io). **Using BrowserStack as remote Selenium Server** @@ -83,7 +83,19 @@ Please note that if you set `sauceUser` and `sauceKey`, the settings for `seleni You can optionally set the `name` property in a capability in order to give the jobs a name on the server. Otherwise they will just be called `Unnamed Job`. +**Using Perfecto as remote Selenium Server** +To run the Protractor scripts on real devices and browswer in Perfecto Lab. +Add the following parameters to your config file: + +Mandatory Parameters + - `perfectoUser` - The username for your Perfecto account. + - `perfectoPassword` - The Password for Perfecto account. + - `perfectoToken` - The token to execute Perfecto web + +Please note that if you set `perfectoUser` and `perfectoPassword`, the settings for `seleniumServerJar`, `seleniumPort`, `seleniumArgs`, `browserstackUser` , `browserstackKey` ,`sauceUser` and `sauceKey` will be ignored. + + Connecting Directly to Browser Drivers -------------------------------------- diff --git a/lib/cli.ts b/lib/cli.ts index 0964e0c1e..d74a3bff1 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -50,6 +50,9 @@ let allowedNames = [ 'sauceSeleniumAddress', 'browserstackUser', 'browserstackKey', + 'perfectoUser', + 'perfectoPassword', + 'perfectoToken', 'directConnect', 'firefoxPath', 'noGlobals', diff --git a/lib/config.ts b/lib/config.ts index 21b34d8eb..6c90a1018 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -191,6 +191,24 @@ export interface Config { */ firefoxPath?: string; + // ---- 6. To use remote browsers via Perfecto --------------------------- + + /** + * If Perfecto user need to provide the credential + * user + */ + perfectoUser ?: string; + /** + * PerfectoPassword + */ + perfectoPassword?: string; + + /** + * PerfectoToken + */ + perfectoToken?: string; + + // --------------------------------------------------------------------------- // ----- What tests to run --------------------------------------------------- // --------------------------------------------------------------------------- diff --git a/lib/driverProviders/index.ts b/lib/driverProviders/index.ts index 40e066a8e..63856198f 100644 --- a/lib/driverProviders/index.ts +++ b/lib/driverProviders/index.ts @@ -6,6 +6,7 @@ export * from './hosted'; export * from './local'; export * from './mock'; export * from './sauce'; +export * from './perfecto'; import {AttachSession} from './attachSession'; @@ -16,6 +17,7 @@ import {Hosted} from './hosted'; import {Local} from './local'; import {Mock} from './mock'; import {Sauce} from './sauce'; +import {Perfecto} from './perfecto'; import {Config} from '../config'; import {Logger} from '../logger'; @@ -42,6 +44,9 @@ export let buildDriverProvider = (config: Config): DriverProvider => { } else if (config.sauceUser && config.sauceKey) { driverProvider = new Sauce(config); logWarnings('sauce', config); + } else if (config.perfectoUser && config.perfectoPassword) { + driverProvider = new Perfecto(config); + logWarnings('perfecto', config); } else if (config.seleniumServerJar) { driverProvider = new Local(config); logWarnings('local', config); @@ -81,6 +86,15 @@ export let logWarnings = (providerType: string, config: Config): void => { if ('sauce' !== providerType && config.sauceKey) { warnList.push('sauceKey'); } + if ('perfecto' !== providerType && config.perfectoUser) { + warnList.push('perfectoUser'); + } + if ('perfecto' !== providerType && config.perfectoPassword) { + warnList.push('perfectoPassword'); + } + if ('perfecto' !== providerType && config.PerfectoToken) { + warnList.push('perfectoToken'); + } if ('local' !== providerType && config.seleniumServerJar) { warnList.push('seleniumServerJar'); } diff --git a/lib/driverProviders/perfecto.ts b/lib/driverProviders/perfecto.ts new file mode 100644 index 000000000..51a9a3a06 --- /dev/null +++ b/lib/driverProviders/perfecto.ts @@ -0,0 +1,38 @@ +/* + * This is an implementation of the SauceLabs 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 {Session, WebDriver} from 'selenium-webdriver'; +import * as util from 'util'; + +import {Config} from '../config'; +import {Logger} from '../logger'; + +import {DriverProvider} from './driverProvider'; + +let logger = new Logger('Perfecto'); +export class Perfecto extends DriverProvider { + constructor(config: Config) { + super(config); + } + + /** + * Configure and launch (if applicable) the object's environment. + * @public + * @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['user'] = this.config_.perfectoUser; + this.config_.capabilities['password'] = this.config_.perfectoPassword; + this.config_.capabilities['securityToken'] = this.config_.perfectoToken; + + logger.info('Using Perfecto server' + this.config_.seleniumAddress); + deferred.resolve(); + return deferred.promise; + } +}