I want to fill a set of data in a repeater component. I am passing number of rows in which data needs to be filled and then passing data from json for all the columns of a row [this data will be repeated in mulitple rows]
There's pagination feature after some set of rows say 10 and then I have to continue entering the data in subsequent pages after moving to the next page in the repeater.
Issues I am facing:
Passing json as a arguement from step definition is not working [Had to pass hard coded value, I want to pass rowRepeaterData in _.each]
Data gets filled correctly in the first page though all the promises are working async, promise.all waits for the promises to get resolved. Recursive function gets called again and works fine but promise.all doesn't waits and application gets closed while I can see promises failing afterwards as elements are not available.
this.fillRowRepeaterData= function(rowRepeaterData,rowRepeaterVariable,rows, currentRow) {
var counter = currentRow,
//activity=JSON.parse(rowRepeaterData),
promises = [];
while (counter < rows) {
_.each(rowRepeaterJson.individualIncludedExcludedWCApp, function (item) {
var element = ('.rowRepeater-' + rowRepeaterVariable + ' .' + 'row' + counter + ' .formFieldComponent-' + item.locator);
promises.push(commonUtilitiesObject.waitFor(by.css(element)).then(function () {
console.log('Inside Promise...');
if (item.fieldType === 'dropdown') {
return formUtil.makeSelectionFromSearchableDropdown(item.value, element);
}
else if (item.fieldType === 'textInputBox') {
return formUtil.sendText(by.css(element), item.value);
}
}))
});
counter++;
if (counter % 10=== 0){
break;
}
}
return Promise.all(promises).then(function (resolve) {
var nextPageButton = '.rowRepeater-' + rowRepeaterVariable + ' .pagingContainer .nextPageButton';
if (counter < rows){
commonUtilitiesObject.click(by.css(nextPageButton)).then (function(){
this.fillRowRepeaterData(rowRepeaterData, rowRepeaterVariable, rows, counter);
}.bind(this));
} else {
console.log('Final resolve');
resolve(true);
}
}.bind(this));
}.bind(this);
JSON:
{
"individualIncludedExcludedWCApp" : [
{"fieldType":"textInputBox","locator":"locationNumber", "value":1},
{"fieldType":"textInputBox","locator":"excludedName", "value":"TestRowRepeater"},
{"fieldType":"textInputBox","locator":"excludedDateOfBirth", "value":"01/01/2018"},
{"fieldType":"textInputBox","locator":"excludedTitle", "value":"Partner"},
{"fieldType":"textInputBox","locator":"excludedOwnershipPercentage", "value":50},
{"fieldType":"textInputBox","locator":"excludedDuties", "value":"Testing of row repeater"},
{"fieldType":"textInputBox","locator":"excludedRemuneration", "value": 12500}
]
}
this.When(/^user fills data in the "([^"]*)" rows of the "([^"]*)" row repeater$/, function (rowNumber,rowRepeaterVariable){
var rowsToFillData = rowNumber,
rowRepeaterData = 'rowRepeaterJson.' +rowRepeaterVariable;
return rowRepeaterUtil.fillRowRepeaterData(rowRepeaterData,rowRepeaterVariable,rowsToFillData,0);
});