Am trying to parametrize capabilities using an excel. Am using npm exceljs package for excel reading and writing. I will give the sample code.
//It will read the value from excel
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 browservalue is Chrome expect to be execute this one
var Chrome = {
browserName: 'chrome',
'chromeOptions': {
'args': ["--disable-infobars"]
}
};
//and browservalue is using here
exports.config = {
capabilities: browserValue,
}
Am not sure what am doing wrong, data is fetching from excel because the print statement was working fine. But am getting an error --\ '[15:53:43] E/launcher - Error: TypeError: Target browser must be a string, but i s ; did you forget to call forBrowser()? '
Am not sure is it possible or not , or something am doing wrong?
Am already gone through the link Parametrize protractor-config file , and How can I use command line arguments in Angularjs Protractor?