Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

It seems grunt protractor runner cannot support params well #121

Closed
pzlvv opened this issue May 21, 2015 · 6 comments
Closed

It seems grunt protractor runner cannot support params well #121

pzlvv opened this issue May 21, 2015 · 6 comments

Comments

@pzlvv
Copy link

pzlvv commented May 21, 2015

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
Copy link

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
Copy link
Author

pzlvv commented May 21, 2015

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
Copy link

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
Copy link
Author

pzlvv commented May 21, 2015

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
Copy link

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
Copy link
Owner

teerapap commented May 7, 2016

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

@teerapap teerapap closed this as completed May 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants