3

For example local, qa, and production.

Each of them has different URL. So I expect to contain something in URL. So I need to take some parameter from console where I run the protractor.

I run protractor like:

gulp protractor

in spring boot.

Each of the environments has different account name so when I run gulp protractor, I need to put account name as parameter:

gulp protractor local accountname

Is that possible?

Or do I have to create 3 different protractor.conf to run for each environment which has different methods for different methods?

  • 2
    You can always write three different gulp tasks that pass in different variables for baseurl, username and password. Example gulp protractor-local, gulp protractor-qa or gulp protractor-production – sonhu Dec 23 '16 at 14:22
3

I was able to accomplish this using a gulp task that accepted an argument representing the environment. You can configure gulp tasks to accept arguments using a tool like yargs and work with Protractor using gulp-protractor

I used this to switch out the baseUrl in the protractor config. Example:

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

gulp.task('protractor', () => {
  const argv = require('yargs')
     .default('env', 'local')
     .argv
  return gulp.src(path_to_tests)
    .pipe(gulpif(argv.env === 'test', protractor({
      configFile: 'path_to_config',
      args: ['--baseUrl', env.testUrl]
   })))
 ...etc
 .on('error', function(e) {throw e; });

Then I could run the tests using gulp protractor --env test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.