I am using protractor to test angularJS apps. I have declared a variable 'logDir' in my test js and want to use it as global variable in other js.
//test.js
var regex = /(.*automation)/;
var result = regex.exec(__dirname);
var baseDir = result[0];
var libDir = baseDir + '/lib';
I want to use libDir variable globally in other js.
I am new to protractor and need help. If more clarification needed, let me know.
Thanks in advance.
You can dump the variable you need globally onto Protractor
browser
object and use it anywhere in the Protractor run Environmentbrowser.libDir = baseDir + '/lib'
;And then if you need it in any other test case you can directly use it as
browser.libDir
A more professional way to handle this would be declaring global variables in
onPrepare()
.