While automating angular 4 app, i need to declare some global variables i.e. myVar = 'John'
. I tried declaring it in protractor.conf but its not working. I already have seen Protractor set global variables but these solutions don't work for me. Is there any solution to this? I am using protractor version 5.4.2.
exports.config = {
//..
params:{
myVar = 'John'
},
//..
}
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
//this global variable
global.myVar = 10000;
browser.waitForAngularEnabled(false);
browser.driver.manage().window().maximize();
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
Thanks in Advance
params is an object and therefore requires
:
to assign the value to myVar, not=
.This is called in the following manner
The second method should work as it is. You just need to call it
Called with