For protractor side check out this page
Per its content, having this in your conf.js
:
module.exports = {
params: {
login: {
email: 'default',
password: 'default'
}
},
// * other config options *
}
you can pass any parameter to it in CMD as follows:
protractor --baseUrl='http://some.server.com' conf.js --parameters.login.email=example@gmail.com
--parameters.login.password=foobar
so you end up having this in your specs:
describe('describe some test', function() {
it('describe some step', function() {
browser.get(browser.baseUrl);
$('.email').sendKeys(browser.params.login.email);
$('.password').sendKeys(browser.params.login.password);
});
});
For Jenkins just construct the command as follows:
protractor --baseUrl=${url} conf.js --parameters.login.email=${email}
--parameters.login.password=${password}
Another way if you want to just pass one parameter is have object in your config.js
with mapping of all related params like this:
let param_mapping = {
prod: {
url: "https://prod.app.com",
email: "prod@gmail.com",
password: "Test1234"
},
dev: {
url: "https://dev.app.com",
email: "dev@gmail.com",
password: "Test1234"
},
stage: {
url: "https://stage.app.com",
email: "stage@gmail.com",
password: "Test1234"
}
};
let parameters = param_mapping[process.ENV.CUSTOM_ENV];
exports.config = {
baseUrl: parameters.url,
params: parameters,
// ...
};
and then start your process with an environment variable:
CUSTOM_ENV=dev protractor protractor.conf.js
Please note, I haven't tested this particular code now, but I did test the logic a little while ago, so this can be your approach