Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Open
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
14 changes: 13 additions & 1 deletion docs/server-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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
--------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ let allowedNames = [
'sauceSeleniumAddress',
'browserstackUser',
'browserstackKey',
'perfectoUser',
'perfectoPassword',
'perfectoToken',
'directConnect',
'firefoxPath',
'noGlobals',
Expand Down
18 changes: 18 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
// ---------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions lib/driverProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './hosted';
export * from './local';
export * from './mock';
export * from './sauce';
export * from './perfecto';


import {AttachSession} from './attachSession';
Expand All @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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');
}
Expand Down
38 changes: 38 additions & 0 deletions lib/driverProviders/perfecto.ts
Original file line number Diff line number Diff line change
@@ -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<any> {
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;
}
}