I am currently working on parameterizing capabilities using an Excel sheet. For this task, I am utilizing the npm exceljs package for both reading and writing data. Below is a snippet of the code that demonstrates how I am trying to achieve this:
//This function reads values from the Excel sheet
this.getValueFromExcel = function getValueFromExcel(cellAddress) {
return workbook.xlsx.readFile('data.xlsx').then(function () {
var worksheet = workbook.getWorksheet(sheetName);
var excelData = worksheet.getCell(cellAddress).value.toString();
console.log(excelData);
return excelData;
})
}
var browserValue = this.getvalueFromExcel(cellAddress);
//If the browser value is Chrome, then execute this configuration
var Chrome = {
browserName: 'chrome',
'chromeOptions': {
'args': ["--disable-infobars"]
}
};
//Using the browservalue here in capabilities
exports.config = {
capabilities: browserValue,
}
I seem to be facing an issue where I'm receiving an error despite successfully fetching data from the Excel sheet. The error message states: '[15:53:43] E/launcher - Error: TypeError: Target browser must be a string, but i s ; did you forget to call forBrowser()?'
I am unsure whether what I am attempting is feasible or if there is something I am missing.
Previously, I have referred to the following links for guidance: Parametrize protractor-config file and How can I use command line arguments in Angularjs Protractor?