Run your angular protractor tests with gulp
Usage
First, install gulp-protractor
as a development dependency:
npm install --save-dev gulp-protractor
Then, add it to your gulpfile.js
:
var protractor = protractor; gulp
Protractor Webdriver
You have to update and start a standalone selenium server. Please read the offical instructions.
You can also ensure that the driver is installed by using the webdriver_update
task. Have a look at the example folder.
You have 2 options to start the selenium server.
The first one is to let Protractor handle it automatically, including stopping it once your tests are done. 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:
// 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. If you decide to start it that way, the task will keep running indefinitely.
var webdriver_standalone = webdriver_standalone;gulp;
API
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
options.debug
Type: Boolean
Default: false
Enables Protractor's debug mode, which can be used to pause tests during execution and to view stack traces.
webdriver_update_specific(options)
options.webDriverManagerArgs
Type: Array
Default: []
// Download and update the selenium drivervar webdriver_update = webdriver_update_specific; // Downloads the selenium webdriver - stupid solution to pass extra args like ignore_sslgulp;
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
:
// gulpfile.js should be in workspace root for this examplevar gulp = ;var path = ;var child_process = ; { var winExt = /^win/? '.cmd' : ''; var protractorBin = path; return path;} gulp; gulp;
You can add command line arguments for protractor behind the gulp task:
gulp protractor-run --specs=runOnlyThisFile.js