teerapap / grunt-protractor-runner

A Grunt plugin for running protractor runner.
MIT License
149 stars 123 forks source link

It seems grunt protractor runner cannot support params well #121

Closed pzlvv closed 8 years ago

pzlvv commented 9 years ago

When using protractor I can pass parameters by adding something like this: --params.key1=value1 Unfortunately it doesn't work for protractor runner. To solve the problem I add some code into the protrotractor_runner.js, and now it's OK for the moment //Add params command line support var cargs = grunt.option.flags(); cargs.forEach(function(a){ if (a.indexOf('--params') ==0){ args.push(a); } })

I hope this feature could be added.

hasanyousuf commented 9 years ago

Hi! You need to pass parameters within the protractor task in your grunt file. Here is small snippet confi: grunt.file.readJSON('config-param.json'), protractor: {

        options: {
            configFile: "config/e2e.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.
            debug: '<%= confi.debugger %>',
            args: {
                params: '<%= confi %>'
            }
        },
        run: {}
    },

and you can access parameters in your specs like . browser.params.fieldName

pzlvv commented 9 years ago

What puzzled me is I want to pass the parameters from the command line because the params is given by other modules. Exp. grunt --gruntfile mygruntfile --params.reportName=report1 where report1 is a variable.

hasanyousuf commented 9 years ago

I donot like to use parameters from command line because it can mess up. I just pass command grunt and it fetches all parameters from my config-params.json and populates my specs with required data.

config-param.json { "reportName":"report1" } then you can access variable in your specs like browser.params.reportName Sorry, I missunderstood but here is my solution. You can generate a json file from other module and use it. I have been working with passing variables from command line and it works.

pzlvv commented 9 years ago

It will be ok if you just need to load the config from one file. However, my challenge is set up a server and there will be more than one task running currently, so I need to generate more than one config file and load these config files respectively. Emm... I don't think it's fun.

spatchamatla commented 9 years ago

we are passing the browser and environments we want to run the protractor tests against, Since there are multiple environments we need to run against, we cant have them in simple json. is there any kind of feature where we can simply pass the protractor cmd line arguments from grunt?

teerapap commented 8 years ago

Current behaviour is you need to pass escaped JSON object string for --params. (Sorry for unclear README.md) Please try this

--params='{ "location":"some url" }'

If you want --params.location.xxx=yyy behaviour, please join the discussion in #148