Another option is to use gruntfile.js and invoke the protractor configuration file.
//gruntfile.js
module.exports = function (grunt) { grunt.registerTask("default", "", function () { }); //Configure main project settings grunt.initConfig({ //Basic settings and infor about our plugins pkg: grunt.file.readJSON('package.json'), //Name of plugin cssmin: { }, protractor: { options: { configFile: "conf.js", // Default config file keepAlive: true, // If false, the grunt process stops when the test fails. noColor: false, // If true, protractor will not use colors in its output. args: { baseUrl: grunt.option('baseUrl') || 'http://localhost:6034/' } }, your_target: { // Grunt requires at least one target to run so you can simply put 'all: {}' here too. options: { configFile: "conf.js", // Target-specific config file args: { baseUrl: grunt.option('baseUrl') || 'http://localhost:63634/' } } }, }, //uglify uglify: { } }); //Load the plugin grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-protractor-runner'); //Do the Task grunt.registerTask('default', ['cssmin']); };
Protractor configuration file: conf.js
exports.config = { directConnect: true, // Capabilities to be passed to the webdriver instance. capabilities: { 'browserName': 'chrome', 'chromeOptions': { args: ['--no-sandbox'] } }, chromeOnly: true, // Framework to use. Jasmine is recommended. framework: 'jasmine', // Spec patterns are relative to the current working directory when // protractor is called. specs: ['specs/*/*_spec.js'], suites : { abcIdentity : 'specs/abcIdentity/*_spec.js' //picks up all the _spec.js files }, params: { UserName: ' abc@test.com ', Password: '123' }, // Options to be passed to Jasmine. jasmineNodeOpts: { defaultTimeoutInterval: 30000, includeStackTrace: true }, onPrepare: function () { browser.driver.manage().window().maximize(); if (process.env.TEAMCITY_VERSION) { var jasmineReporters = require('jasmine-reporters'); jasmine.getEnv().addReporter(new jasmineReporters.TeamCityReporter()); } } };
// To run with the default URL http: // localhost: 6034
grunt protractor
// To run with any other URL
grunt protractor --baseUrl:"http://dev.abc.com/"
source share