Skip to content

Commit

Permalink
README updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Raut committed Mar 24, 2017
1 parent 714f642 commit 9254186
Showing 1 changed file with 48 additions and 17 deletions.
65 changes: 48 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ npm install --save-dev gulp-protractor
Then, add it to your `gulpfile.js`:

```javascript

var protractor = require("gulp-protractor").protractor;

gulp.src(["./src/tests/*.js"])
.pipe(protractor({
configFile: "test/protractor.config.js",
args: ['--baseUrl', 'http://127.0.0.1:8000']
}))
.on('error', function(e) { throw e })
.pipe(protractor({
configFile: "test/protractor.config.js",
args: [
'--baseUrl', 'http://127.0.0.1:8000',
'--suite', 'login',
'--params.environment', 'test'
]
}))
.on('error', function(e) { throw e })
```

### Protractor Webdriver

You have to update and start a standalone selenium server. [Please read the offical instructions](https://github.com/angular/protractor#appendix-a-setting-up-a-standalone-selenium-server).

You can also ensure that the driver is installed by using the `webdriver_update` task. Have a look at the example folder.
Expand All @@ -34,9 +40,11 @@ The first one is to let Protractor handle it automatically, including stopping i
To do that, simply point to the selenium jar in the protractor config file (you will need to update the version number accordingly) instead of the address:

```javascript

// The file path to the selenium server jar ()
seleniumServerJar: './node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.2.0.jar',
// seleniumAddress: 'http://localhost:4444/wd/hub',

```

The second option is to let the gulp task handle it with the built-in webdriver snippet.
Expand All @@ -52,54 +60,77 @@ gulp.task('webdriver_standalone', webdriver_standalone);
### protractor(options)

#### options.configFile

Type: `String`
Default: `null`

The path to your protractor config

#### options.args

Type: `Array`
Default: `[]`

Arguments get passed directly to the protractor call [Read the docs for more information](https://github.com/angular/protractor/blob/master/docs/getting-started.md#setup-and-config)

#### options.debug

Type: `Boolean`
Default: `false`

Enables Protractor's [debug mode](https://github.com/angular/protractor/blob/master/docs/debugging.md), which can be used to pause tests during execution and to view stack traces.

### webdriver_update_specific(options)

#### options.webDriverManagerArgs

Type: `Array`
Default: `[]`

```javascript
// Download and update the selenium driver
var webdriver_update = require('gulp-protractor').webdriver_update_specific;

// Downloads the selenium webdriver - stupid solution to pass extra args like ignore_ssl
gulp.task('webdriver_update', webdriver_update({
webdriverManagerArgs: ['--ignore_ssl']
}));
```

## Running Protractor without a plugin

# Running Protractor without a plugin
If you want to avoid using a plugin at all, here are gulp tasks which install the webdriver and start protractor:

First install the protractor package:

```npm install --save-dev protractor```

Then add these tasks to your ```gulpfile.js```:

```javascript

// gulpfile.js should be in workspace root for this example
var gulp = require('gulp');
var path = require('path');
var child_process = require('child_process');

function getProtractorBinary(binaryName){
var winExt = /^win/.test(process.platform)? '.cmd' : '';
var pkgPath = require.resolve('protractor');
var protractorDir = path.resolve(path.join(path.dirname(pkgPath), '..', 'bin'));
return path.join(protractorDir, '/'+binaryName+winExt);
var winExt = /^win/.test(process.platform)? '.cmd' : '';
var protractorBin = path.join('node_modules', '.bin', binaryName);
return path.join(protractorBin, winExt);
}

gulp.task('protractor-install', function(done){
child_process.spawn(getProtractorBinary('webdriver-manager'), ['update'], {
stdio: 'inherit'
}).once('close', done);
child_process.spawn(getProtractorBinary('webdriver-manager'), ['update'], {
stdio: 'inherit'
}).once('close', done);
});

gulp.task('protractor-run', function (done) {
var argv = process.argv.slice(3); // forward args to protractor
child_process.spawn(getProtractorBinary('protractor'), argv, {
stdio: 'inherit'
}).once('close', done);
var argv = process.argv.slice(3); // forward args to protractor
child_process.spawn(getProtractorBinary('protractor'), argv, {
stdio: 'inherit'
}).once('close', done);
});

```
Expand Down

0 comments on commit 9254186

Please sign in to comment.