I want to retrieve a value in 'Given' function and then store it in a global variable so that the value is accessible in subsequent steps of a scenario in protractor cucumber typescript based automation project.
1 Answer
Go to your conf.js file and create an onPrepare function, there you can define and initialize a global variable. Below is a sample:
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
baseUrl: "http://url.com",
specs: ['./*_specs.js'],
onPrepare: function() {
browser.driver.manage().window().maximize();
//create a global variable like below
global.variableName = "hello";
}
}