I used export E2E_USER=username
and that worked.
How can I use System Environment Variables in Angularjs Protractor?
-
07-07-2023 - |
Pergunta
My plan is to store a username and password as system environment variables and reference them in an Angularjs Protractor config file. I defined the variables in /etc/environment
. This is what I've tried so far:
params: {
login: {
user: $E2E_USER,
pass: $E2E_PASS
}
}
I also tried this:
params: {
login: {
user: process.env.E2E_USER,
pass: process.env.E2E_PASS
}
}
Any help would be much appreciated!
Solução
Outras dicas
You have to use process.env.YOUR_ENV
in NodeJS, so for example inside onPrepare function, not directly inside params:
exports.config = {
onPrepare: function() {
//load env variables for testing
if (typeof process.env.URL !== "undefined") {
browser.baseUrl = process.env.URL;
console.log('Base URL = ' +process.env.URL);
}
},
params: { ...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow