From 4aed29c5385abe1919051b08c5065dcdced5374e Mon Sep 17 00:00:00 2001 From: uzie Date: Thu, 14 Sep 2017 10:57:31 -0400 Subject: [PATCH 1/3] Add instructions to connect Perfecto as a remote Selenium server --- docs/server-setup.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/server-setup.md b/docs/server-setup.md index e9dfb36c8..49953a646 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 -------------------------------------- From ba1018e53101e6d5e090c90ffcbbe6f73e9fe6a4 Mon Sep 17 00:00:00 2001 From: uzie Date: Thu, 14 Sep 2017 14:41:30 -0400 Subject: [PATCH 2/3] add Perfecto as a remote Selenium server (data provider) --- docs/server-setup.md | 8 +++---- lib/cli.ts | 3 +++ lib/config.ts | 18 +++++++++++++++ lib/driverProviders/index.ts | 14 ++++++++++++ lib/driverProviders/perfecto.ts | 40 +++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 lib/driverProviders/perfecto.ts diff --git a/docs/server-setup.md b/docs/server-setup.md index 49953a646..45f0cbaa7 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -89,11 +89,11 @@ 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 + - `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. +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..39c46619a --- /dev/null +++ b/lib/driverProviders/perfecto.ts @@ -0,0 +1,40 @@ +/* + * 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(); + console.log("In Perfectot "+this.config_.perfectoUser) + + 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; + } +} From 4e217b502d64f04646f150f55c0a60325418b43e Mon Sep 17 00:00:00 2001 From: uzie Date: Thu, 14 Sep 2017 14:43:08 -0400 Subject: [PATCH 3/3] remove log --- lib/driverProviders/perfecto.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/driverProviders/perfecto.ts b/lib/driverProviders/perfecto.ts index 39c46619a..51a9a3a06 100644 --- a/lib/driverProviders/perfecto.ts +++ b/lib/driverProviders/perfecto.ts @@ -27,8 +27,6 @@ export class Perfecto extends DriverProvider { */ protected setupDriverEnv(): q.Promise { let deferred = q.defer(); - console.log("In Perfectot "+this.config_.perfectoUser) - this.config_.capabilities['user'] = this.config_.perfectoUser; this.config_.capabilities['password'] = this.config_.perfectoPassword; this.config_.capabilities['securityToken'] = this.config_.perfectoToken;